Revision: 1325 Author: bvwelch Date: Tue Sep 15 12:33:04 2009 Log: revise for socket-CAN compatibility
http://code.google.com/p/jallib/source/detail?r=1325 Modified: /trunk/include/protocol/canopen.jal ======================================= --- /trunk/include/protocol/canopen.jal Wed Aug 26 14:30:51 2009 +++ /trunk/include/protocol/canopen.jal Tue Sep 15 12:33:04 2009 @@ -10,16 +10,20 @@ -- Sources: Cia DS 301 version 4.02 -- +-- Note that we are using dword (32-bit) for cob_id for socket-CAN compatibility. + +-- FIXME: how to truly support 'extended' 29-bit CAN identifiers? + -- format the COB-ID, which is a 'standard' 11-bit CAN identifier. -- the function code is upper 4 bits, the node_id is lower 7 bits. -procedure co_encode_cob_id(byte in func, byte in node_id, word out cob_id) is +procedure co_encode_cob_id(byte in func, byte in node_id, dword out cob_id) is func = func & 0x0F node_id = node_id & 0x7F - cob_id = ( word(func) << 7 ) | word(node_id) + cob_id = ( dword(func) << 7 ) | dword(node_id) end procedure -- extract function code and node_id from 11-bit cob_id -procedure co_decode_cob_id(word in cob_id, byte out func, byte out node_id) is +procedure co_decode_cob_id(dword in cob_id, byte out func, byte out node_id) is cob_id = cob_id & 0x7FF func = byte(cob_id >> 7) node_id = byte(cob_id & 0x7F) @@ -28,14 +32,14 @@ -- send standard 11-bit CANopen message -- FIXME: we are only using one of the TX buffers (3 are available) -- FIXME: handle timeout -procedure co_send(word in cob_id, byte in data[8], byte in len) is +procedure co_send(dword in cob_id, byte in data[8], byte in len) is while can_send(0, cob_id, data, len) == 0 loop end loop end procedure -- receive standard 11-bit CANopen message -- FIXME: we are assuming rollover is set up from RXB0 to RXB1 -- FIXME: handle timeout -procedure co_receive(word out cob_id, byte out data[8], byte out len) is +procedure co_receive(dword out cob_id, byte out data[8], byte out len) is while can_receive(1, cob_id, data, len) == 0 loop end loop end procedure --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jallib" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/jallib?hl=en -~----------~----~----~----~------~----~------~--~---
