IAR STM32: Failed to load flash loader的问题

2009-12-11 18:38 | 分类:未分类 | 作者:lyg | 574 views

其出错码包括:

The debugging session could not be started.

Either the debugger initialization failed,or else the file

……was corrupt or of an unsupported format.There might be more information in the Debug Log window

http://www.manley.com.cn/web/Service.asp

原因可能不一样,我碰到的是当我从从mainley下载其演示程序后(5.30版本),在IAR5.30.1版本上运行时出现的错误。

需要在其debug选项中将driver由st_link改成Third-party driver。然后在third-party driver选项卡中将IAR debuger driver关联到STM32DriverV5.dll(比如我的:C:\Manley\Drivers\STLink\STM32DriverV5.dll)

重新编译即可。

希望对遇到相似情况的人有所帮助

 

使用新版本Python(>=2.6)可能遇到如下错误,在动态链接的时候,ERROR: Failure: ImportError (DLL load failed: 找不到指定的模块。)

2009-08-30 17:29 | 分类:Python, 未分类, 编程语言 | 标签:, , , , , | 作者:lyg | 456 views

ERROR: Failure: ImportError (DLL load failed: 找不到指定的模块。)

 

如果遇到此种之错误,或是类似,那么

Traceback (most recent call last):
  File "D:\Tools\Building\Python\lib\site-packages\nose-0.11.1-py2.6.egg\nose\loader.py", line 379, in loadTestsF
    addr.filename, addr.module)
  File "D:\Tools\Building\Python\lib\site-packages\nose-0.11.1-py2.6.egg\nose\importer.py", line 39, in importFro
    return self.importFromDir(dir_path, fqname)
  File "D:\Tools\Building\Python\lib\site-packages\nose-0.11.1-py2.6.egg\nose\importer.py", line 86, in importFro
    mod = load_module(part_fqname, fh, filename, desc)
  File "D:\svn\hgsubversion\tests\test_fetch_renames.py", line 4, in <module>
    import test_util
  File "D:\svn\hgsubversion\tests\test_util.py", line 20, in <module>
    from hgsubversion import util
  File "D:\svn\hgsubversion\hgsubversion\__init__.py", line 40, in <module>
    from svn import core
  File "D:\Tools\Building\Python\lib\site-packages\svn\core.py", line 19, in <module>
    from libsvn.core import *
  File "D:\Tools\Building\Python\lib\site-packages\libsvn\core.py", line 5, in <module>

ERROR: Failure: ImportError (DLL load failed: 找不到指定的模块。)

 

 

比如此时,最后一条语句

  File "D:\Tools\Building\Python\lib\site-packages\libsvn\core.py", line 5, in <module>

表明当中的dll文件找不到,一般是不小心吧不应该命名成pyd的文件命名成了pyd。

 

比如当前libsvn下包含了如下文件

卷序列号为 284E-138E
D:.
    client.py
    client.pyc
    core.py
    core.pyc
    delta.py
    delta.pyc
    diff.py
    fs.py
    libsvn_swig_py-1.dll
    ra.py
    ra.pyc
    repos.py
    wc.py
    wc.pyc
    _client.pyd
    _core.pyd
    _delta.pyd
    _diff.pyd
    _fs.pyd
    _ra.pyd
    _repos.pyd
    _wc.pyd
    __init__.py
    __init__.pyc

 

这个是可以正常运行的文件结构

其中.pyd文件结尾的文件其实均是dll文件,只是rename了

但是为何    libsvn_swig_py-1.dll却没有重命名呢?

这里是有一个问题在里面的。。

首先。凡是已pyd 文件结尾为的都是.py文件里面直接import的

比如_core.pyd 在 core.py 里面有 import _core 这样的语句

而所有dll文件是不会直接被python调用的,所以必须添加到PATH路径里面,就是说只能够间接被.pyd文件应用,而不能直接被.pyd直接引用。

 

因此,如果下载的包中,诸如_core.dll _fs.dll 这种以_开头的大约是要被py文件引用的,所以要重命名为.pyd文件

而诸如libsvn_swig_py-1.dll文件则不能命名为.pyd文件后缀,同时这些文件所处的路径要添加到PATH中,否则会找不到。。

 

还有一个重要问题,就是程序的位不匹配,比如32为之于64为,这也是要重点考虑的,所以

在这种情况之下,要使用32位的,因为很多app都没有64位版本。。。。。

除非可以确定整个程序链都是64位的,这样才可以使用64位的程序

比如我就在这里遇到麻烦了,我用的subversion是64位的,python是64为的,

可是有一个东西不是,那就是subversion python bind 不是,所以无法正常的运行,也会出现这种load错误

就是说动态链接库也要是64位的才能够正常工作,dll hell

综上所述,就是这样子了。

人性化的emacs shortcut

2009-08-29 23:21 | 分类:emacs, 未分类, 编辑器 | 标签:, , , , , , , , , , , , , , , | 作者:lyg | 125 views

http://code.google.com/p/ergoemacs

 

这个网页上有这个快捷键模版

C++中不可继承的类

2009-08-24 22:43 | 分类:C/C++, 原创, 编程语言 | 标签:, | 作者:Aaron | 164 views

如何让C++中的类变得不可继承呢?最笨的办法就是人为约定喽~呵呵~再仔细想一想可能会想到如下用法:

class A
{
private:
    A(){}
public:
    static A * Create();
};

这有点像singleton的使用方法,但是这种模式用在不可继承的类上面就显得有点不伦不类了。我甚至还见有人用template来实现这个,真是鸡肋鸡肋。。。下面介绍两种方法,个人觉得还是比较漂亮的~(以下代码就懒的讲解了,大家自己看吧)

class COrphanTag
{
protected:
    COrphanTag(){}
};
 
class COnly : private virtual COrphanTag
{
public:
    COnly(){}
};
 
class CMore : public COnly
{
public:
    CMore(){}
};
 
int main(void)
{
    COnly only;
    return 0;
}

但是这个程序在VC6下是可以正常编译通过的,哎,没办法,必须顺着微软来啊,那我们再改改:

class COnly;
class COrphanTag
{
private:
    COrphanTag(){}
    friend class COnly;
};
 
class COnly : private virtual COrphanTag
{
public:
    COnly(){}
};
class CMore : public COnly
{
public:
    CMore(){}
};
 
int main(void)
{
    COnly only;
    return 0;
}

嗯,这样就可以了,大家都能成功的报错了吧~但是如果有人使用如下的多继承那就无语了:

class CMore : public COnly, public virtual COrphanTag
{
public:
    CMore(){}
};

毕竟C++没有JAVA中final那种东西啊。。。

likely,unlikely宏与GCC内建函数__builtin_expect()

2009-06-17 20:41 | 分类:Linux, 转载 | 标签:, , , | 作者:Aaron | 238 views

在读linux/kernel/fork.c的时候遇到了unlikely宏定义,一路追踪,最后找到了GCC内建函数__builtin_expect(),查阅GCC手册,发现其定义如下:

long __builtin_expect (long exp, long c)                                    [Built-in Function]
You may use __builtin_expect to provide the compiler with branch prediction
information. In general, you should prefer to use actual profile feedback for this
(‘-fprofile-arcs’), as programmers are notoriously bad at predicting how their
programs actually perform. However, there are applications in which this data is
hard to collect.
The return value is the value of exp, which should be an integral expression. The
value of c must be a compile-time constant. The semantics of the built-in are that it
is expected that exp == c. For example:
if (__builtin_expect (x, 0))
foo ();
would indicate that we do not expect to call foo, since we expect x to be zero. Since
you are limited to integral expressions for exp, you should use constructions such as
if (__builtin_expect (ptr != NULL, 1))
error ();
when testing pointer or floating-point values.

大致是说,由于大部分程序员在分支预测方面做得很糟糕,所以GCC提供了这个内建函数来帮助程序员处理分支预测,优化程序。其第一个参数exp为一个整型表达式,这个内建函数的返回值也是这个exp,而c为一个编译期常量,这个函数的语义是:你期望exp表达式的值等于常量c,从而GCC为你优化程序,将符合这个条件的分支放在合适的地方。

因为这个程序只提供了整型表达式,所以如果你要优化其他类型的表达式,可以采用指针的形式。

unlikely的定义如下:

#define unlikely(x)  __builtin_expect(!!(x), 0)

也就是说我们期望表达式x的值为0,从而如果我们用

…….

if(unlikely(x)){

bar();

}
来测试条件的话,我们就不期望bar()函数执行,所以该宏的名字用unlikely也就是不太可能来表示。

likely宏与次类似.

说到底__builtin_expect函数就是为了优化可能性大的分支程序。

CUnit使用简介

2009-06-13 16:17 | 分类:CUnit, 原创 | 标签:, | 作者:Aaron | 733 views

一、介绍

继Junit CppUnit的成功后, c语言环境下也出现了开发源码的白盒测试用例CUnit。CUnit以静态库的形式提供给用户使用,用户编写程序的时候直接链接此静态库就可以了。它提供了一个简单的单元测试框架,并且为常用的数据类型提供了丰富的断言语句支持。

二、结构框架

在CUnit的主页上可以看到对他结构的简单描述

                   Test Registry
                        |
         ——————————
         |                            |
      Suite ‘1′      . . . .       Suite ‘N’
         |                            |
   —————             —————
   |             |             |             |
Test ‘11′ … Test ‘1M’     Test ‘N1′ … Test ‘NM’

CUnit的测试是单线程启动,只能注册一个测试用例Test Registry,测试用例下可以注册多个测试套件Suite,每个套件下可以注册多个测试函数Test,每个测试函数里又可以写多个断言ASSERT。

全文阅读 »

单件(Singleton)模式的实现

2009-06-01 10:21 | 分类:C/C++, 原创, 设计模式 | 标签:, , | 作者:Aaron | 240 views

熟悉设计模式的朋友一定知道著名的Singleton吧,如果不知道的话那就先去拜读一下GoF的大作吧,我在这里就不详细介绍了。

直接给大家共享出我们的实现方法,使用的是C++的template。

 

// singleton.h
#ifndef _SINGLETON_H_
#define _SINGLETON_H_
 
template<class T> class Singleton
{
    protected:
        Singleton() {}
        Singleton( const Singleton & ) {}
        Singleton &operator = (Singleton &) {}
 
        static T* pInst;
 
    public:
        static T* GetInstance()
        {
            if (pInst)
                return pInst;
            pInst = new T;
            return pInst;
        }
 
        static void ReleaseInstance()
        {
            if (pInst)
            {
                delete pInst;
                pInst = NULL;
            }
        }
};
 
template<class T> T *Singleton<T>::pInst = 0;
 
#endif
// suraid.h
#ifndef _SURAID_H_
#define _SURAID_H_
 
#include "singleton.h"
 
class Suraid : public Singleton<Texture>
{
    public:     
        Suraid();
};
 
#endif
// main.cpp
#include "suraid.h"
 
int main(void)
{
    Suraid* suraid = Suraid::GetInstance();
    return 0;
}

代码应该很清晰了吧,这样实现的好处就是很方便,想使用单件的时候只要简单的继承一下就好了,但是也有一个缺点,通常我们理解的singleton都是不让实例化的,因为只能实例化一次,但是由于template的特性,构造函数无法申明成protected,也就导致可以实例化类,在使用的过程中要多加注意。

[原创]ecshop 分析(4) 添加自己的模板

2009-04-22 20:01 | 分类:Web开发, ecshop, 原创 | 标签:, , | 作者:Tommy | 755 views

上次我们主要讨论了关于模板的问题,最后我们留下了一个问题——cache的问题。我觉得这个问题到目前位置先不要讨论好,再往后一点我们再来分析这个问题。到现在我们知道了模板的一些操作了,但是我们还是很郁闷,因为我们只是在ecshop的前台框架的控制之下。那么我们如何能够脱离出来呢?如果我们能做到自己添加属于自己或者可以放自己想要放的东西的模板,那么应该算是到了一个更高的台阶来看ecshop了。

要做到添加一个模板就必须做到前台可以显示这个模板,后台可以编辑这个模板。下面我们一步一步教大家怎么添加一个属于自己的模板。在添加之前我们先稍微分析一下,对以一个模板,在前台一定有一个php文件和它对应(很显然这个php文件就是实现给这个模板文件传送数据的)。并且在后台可以编辑这个模板对于的模块,也就是在模板管理——设置模板中有你加的模板的选项。下面我们来添加一个home模板。首先在根目录下新建home.dwt和home.php。然后将index.dwt和index.php中的内容分别拷贝到home.dwt和home.php中。对于这个模板的内容完全由你自己决定,你的内容就会决定你要怎么修改home.dwt和home.php。当然这个模板的内容是受限制的,首先要home这个模板的候选的库文件是存在的。这个是什么意思呢?这句话的意思就是对于每个模板文件,可以调用的库文件是固定的,并且这些可以调用的库文件在文件admin/includes/lib_templete.php中定义的。首先要在后台将home这个模板放入到可设置内容的模板中,部分代码如下:

全文阅读 »

[转]Chrome启动参数方案

2009-04-17 00:59 | 分类:Chrome, 浏览器 | 标签:, , | 作者:lyg | 859 views
下面是常用的一些启动参数:
–user-data-dir=UserDataDir   自定义用户数据目录
–start-maximized   启动就最大化
–no-sandbox   取消沙盒模式
–single-process   单进程运行
–process-per-tab   每个标签使用单独进程
–process-per-site   每个站点使用单独进程
–in-process-plugins   插件不启用单独进程
–disable-popup-blocking   禁用弹出拦截
–disable-javascript   禁用JavaScript
–disable-java   禁用Java
–disable-plugins   禁用插件
–disable-images   禁用图像
 
A Complete list to Google Chrome Startup Switches…
see below
 
-disable-hang-monitor
-disable-metrics
-disable-metrics-reporting
-assert-test
-renderer-assert-test
-crash-test
-renderer-crash-test
-renderer-startup-dialog
-plugin-startup-dialog
-testshell-startup-dialog
-plugin-launcher
-channeltesting-channel
-homepagestart-renderers-manuallyrenderer
-renderer-pathplugin
-single-process
-process-per-tab
-process-per-site
-in-process-plugins
-no-sandbox
-safe-plugins
-trusted-plugins
-test-sandbox
-user-data-dir
-appupload-file
-dom-automation
-plugin-pathjs-flags
-geoidlangdebug-children
-wait-for-debugger-children
-log-filter-prefix
-enable-logging
-dump-histograms-on-exit
-disable-logging
-remote-shell-port
-uninstallomnibox-popup-count
-automation-channel
-restore-last-session
-record-mode
-playback-mode
-no-events
-hide-icons
-show-icons
-make-default-browser
-proxy-server
-dns-log-details
-dns-prefetch-disable
-debug-print
-allow-all-activex
-disable-dev-tools
-always-enable-dev-tools
-memory-model
-tab-count-to-load-on-session-restore
-memory-profile
-enable-file-cookies
-start-maximized
-enable-watchdogfirst-run
-message-loop-strategy
-message-loop-histogrammer
-importsilent-dump-on-dcheck
-disable-prompt-on-repost
-disable-popup-blocking
-disable-javascript
-disable-java
-disable-plugins
-disable-images
-use-lf-heap
-new-http
 
本文来源于谷歌Chrome中文站 http://www.downdig.com/chrome , 原文地址: http://www.downdig.com/chrome/?p=88 
Pages: 1 2 3 4 5 6 7 8 ...12 13 14 Next