20楼#
发布于:2004-01-09 17:30
或者
void YourTask(void *pdata) { 用户代码; OSTaskDel(OS_PRIO_SELF); } |
|
21楼#
发布于:2004-01-09 17:31
对于只执行一次的任务用第二中形式,对于要执行很多次的任务就要用第一种形式,但
是他们都有一个共同点,都需要一个UC/OS的系统调用来保证函数不返回和让出CPU资源 。上面的第二种形式很象DOS下的顺序程序设计,第二种形式就很像windows下的基于消 息驱动的程序设计了(我不是很清楚windows下的程序是在循环的检测消息的到来,还是 在等待消息的到来,有的书上说是前者,但是我的理解和从实际的运行情况看,应该是 后者)。 |
|
22楼#
发布于:2004-01-09 17:31
另外还要说一下的是,函数中的参数 *pdata;这个是UC/OS传递给任务的参数,就象DOS程
序设计中main函数的argv 和argc,只不过这里只能传一个参数了。 |
|
23楼#
发布于:2004-01-09 17:31
2. 全局的变量和代码重用:
因为DOS是一个单任务操作系统,所以编程时不用考虑代码的重用,但是在UC/OS这样的 多任务内核下面,就该考虑代码重用了。也就是任务函数可重入。其实保证可重入很简 单,就是不用全局变量。因为每个任务的局部变量都是放在当前的任务堆栈中的,而任 务堆栈是独立的,所以只要不用全局变量就可以保证代码重用了。 |
|
24楼#
发布于:2004-01-09 17:31
3. 类似于windows下消息驱动的程序的实现(这部分内容我也只是一个设想,欢迎大家
讨论) windows编程比较容易,第一是因为C++的面向对象编程,另外一个我想就是windows本身 的消息驱动机制了。前者保护了数据,而后者帮程序员处理了很复杂的程序逻辑。在其 他的OS下面也有基于事件驱动的机制,但是比起windows下面的消息驱动来说,功能上要 小多了。UC/OS也有事件驱动的机制,利用他的这个机制,编写类似于windows下的消息 驱动的程序是可行的。 |
|
25楼#
发布于:2004-01-09 17:32
其实具体的实现就是利用UC/OS的消息队列。这样,在编写你的任务代码时,先做完任务
的初始化,然后在消息循环中就wait在一个消息上面,然后当其他任务或者中断服务程 序发消息来后,根据消息的内容调用相应的函数模块,函数调用后又回到消息循环,继 续等待消息。 |
|
26楼#
发布于:2004-01-09 17:32
任务函数的样子
void YourTask(void * pdata) { init();/*任务初始化 for(;;) { /*消息循环 OSQPend(); Switch(Qresult) { } } } |
|
27楼#
发布于:2004-01-09 17:32
4.示例
因为看UC/OS还没有多久,也没有实际的做过事情,下面根据BBS上的有关数据采集的 问题写写我设想的任务函数。 |
|
28楼#
发布于:2004-01-09 17:32
Void myTask(void *pada) {
Collect_rate=50; /* set the rate of collecting StartCollect(); /* start the collecting For(;;) { OSSemPost(); /* wait for a interrupt from the A/D collecter HandleCollect(); /* Handle the data from the A/D collecter } } |
|
29楼#
发布于:2004-01-09 17:33
三、 系统调用
请参考《UC/OS-II――源代码开放的实时嵌入式操作系统》第11章。 -- |
|
30楼#
发布于:2004-01-09 17:34
我在用pc机作为目标机,想通过网络来加载VxWorks,在tornado中作好了for 486的bsp,修改了bsp中的config.h,配置了引导行等相关设置,开启并配置了ftp服务器,我认为一切调试流程都没有错误,可是当目标机启动后,引导盘能正常引导,但是他不能打通网络,从主机通过网络正常ftp过来vxworks映像,每次实验加载都失败,为什么?
|
|
31楼#
发布于:2004-01-09 17:34
我用的是3C905网卡,我的config.h中的默认引导行是这样定义的:
|
|
32楼#
发布于:2004-01-09 17:34
#define DEFAULT_BOOT_LINE \\
\"elPci(0,0)host:f:\\\\project\\\\project4\\\\default\\\\vxworks h=192.0.5.36 e=192.0.5.51 g=192.0.5.1 u=target pw=target tn=target\" 网卡类型也选了: /* Network driver options */ #define INCLUDE_END /* Use Enhanced Network Drivers */ #undef INCLUDE_ULTRA /* include SMC Elite16 Ultra interface */ #undef INCLUDE_ENE /* include Eagle/Novell NE2000 interface */ #undef INCLUDE_ELT /* include 3COM EtherLink III interface */ #undef INCLUDE_ESMC /* include SMC 91c9x Ethernet interface */ #undef INCLUDE_FEI /* include Intel Ether Express PRO100B PCI */ #define INCLUDE_SLIP /* include serial line interface */ #define SLIP_TTY 1 /* serial line IP channel COM2 */ #undef INCLUDE_ELC /* include SMC Elite16 interface */ #undef INCLUDE_EEX /* include INTEL EtherExpress interface */ #undef INCLUDE_EEX32 /* include INTEL EtherExpress flash 32 */ #undef INCLUDE_EX /* include Excelan Ethernet interface */ #undef INCLUDE_ENP /* include CMC Ethernet interface*/ #undef INCLUDE_SM_NET /* include backplane net interface */ #undef INCLUDE_SM_SEQ_ADDR /* shared memory network auto address setup */ #define INCLUDE_EL_3C90X_END /* 3com fast etherLink XL PCI */ #undef INCLUDE_LN_97X_END /* AMD 79C972 END DRIVER */ |
|
33楼#
发布于:2004-01-09 17:34
目标机出错信息如下:
Attached TCP/IP interface to elPci0, Attatching network interface lo0...done. Loading...(长时间没反应) |
|
34楼#
发布于:2004-01-09 17:35
最后显示:
Error loading file: errno=0xd0003 (此时从主机无法ping通目标机) |
|
35楼#
发布于:2004-01-09 17:35
config.h中的默认引导行改为的:
#define DEFAULT_BOOT_LINE \\ \"elPci(0,0)host:vxworks h=192.0.5.36 e=192.0.5.51 g=192.0.5.1 u=target pw=target tn=target\" |
|
36楼#
发布于:2004-01-09 17:35
目标机的屏幕显示:
: : Attached TCP/IP interface to elPci0, Attaching network interface lo0...done. Loading... (停顿了几分钟,然后继续显示) Error loading file : errno=0xd0003. Breakpoint Program Counter:0x0000bad5 Status Register:0x00000216 Task:0xfed9778 \"tBoot\"(光标停滞在此,机子发出鸣响) 注:从目标机启动后,主机就一直不停地ping目标机,但ping不通。 ----------------------------- 主机的ftp显示: [L 0450] 02/27/02 21:48:18 Connection accepted from 192.0.5.51 [C 0450] 02/27/02 21:48:18 QUIT or close - user logged out -------------------------------- 另外,我试了一下直接从软盘加载vxworks映像,将Bootline改成: \"fd=0,0(0,0)host:/fd0/vxWorks h=192.0.5.36 e=192.0.5.51 g=192.0.5.1 u=target pw=target tn=target o=elPci0\",并将系统自带的C:\\Tornado\\target\\proj\\pc486_vx\\defaul\\vxworks拷到了软盘上。启动后,可以加载vxworks映像,并显示了 : : Attaching floppy disk...done. Loading /fd0/vxworks 531600+12344+33040 Starting at 0x108000... 在此之后显示: muxDevLoad failed for device entry0 ! Attaching interface lo0...done. WdbConfig:error Configuring WDB Communication interface VxWorks Copyright... : : 0x7ffee7c(tRootTask):muxLoad failed!(光标停滞在此) |
|
37楼#
发布于:2004-01-09 17:36
这是你的网卡驱动程序跟网卡不完全匹配造成的。
换是最好的,用3c905-FX,3C905-BT,3C905-BT4或者是ne2000兼容的网卡都可。要是你有3c905驱动的源码,你或许可以通过修改源码取得对3c905-TX的支持. |
|
38楼#
发布于:2004-01-09 17:37
你还没有登录论坛
|
|
上一页
下一页