2009-03-01 13:27:07 UTC
Hi Janez,
This weekend I started with porting to eCos. I have some suggestions and I am unclear with some things.
Suggestions:
============
1) I noticed that there are hard coded error codes in CO_Driver.c, but these error codes have its defines in the CO_emergency.h header. Can we put then info separate header and use/include them from both places?
e.g. The code like
CANmodule->errorFlags |= 0x2000; //ERROR_TPDO_OUTSIDE_WINDOW
can be replaced by
CANmodule->errorFlags |= (1 << ERROR_TPDO_OUTSIDE_WINDOW);
the right side is evaluated at compile time so I cannot see any problem here to make code more consistent.
2) The other thing ade defines for can messages (CO_CANtxMsg_t, CO_CANrxMsg_t). It seems that they are customizable by driver according placement in CO_driver.h, but they are not isolated enough from CAN stack code. I am not sure about the CO_CANtxMsg_t structure, but the CO_CANrxMsg_t structure has at least two members (data,DLC) which are accessed from can stack code. I would like define TX/RX message as a typedef to eCos structures but they have different names for these members. Can ve isolate them. i.e. provide just forward declarations by typedefs in CO_Driver.h but define them in CO_Driver.h and provide accessor functions which are needed. So far I know about two - for DLC and for data itself.
3) I really cannot reuse example, because it is very platform dependent, so it seems that example should be moved into subdirectory and example should be renamed to Examples. By this way I can create my own example at the same level.
Here is an example of structure
Examples
dsPIC3x
eCos
Confusion:
==========
The eCos already contains CAN driver implementation, so I have upper layer API. (http://ecos.sourceware.org/docs-latest/ref/io-can.html). I am unclear and confused about following stuff.
CANmodule->transmittingAborted counter
CANmodule->bufferInhibitFlag flag
CO_CANclearPendingSyncPDOs() function
More precisely I am unclear how to implement then in eCos. It is all related to PDOs, which I don't need right now.
The eCos maintains its own queue (it is called buffer in doc) which is configurable. The default length of the queue is 64. So when I send TX message it is synchronously enqueued and call is returned back. There is an IOCTL command by which I can wait for real sending of all CAN messages in queue. I cannot wait for specific message. So I cannot check that PDO message was sent in given syncWindows interval.
Can you please explain reason and functionality of these three things.
Thanks
With regards
Bronislav Gabrhelik