1
0
Fork 0
Commit graph

132 commits

Author SHA1 Message Date
Janez
09bf926856 CO_ODinterface - Change some API:
- Add OD_getPtr_vs(), OD_getPtr_os() and OD_getPtr_us().
- Move read/write from OD_subEntry_t into OD_IO_t structure.
- Change argument in OD_getSub(), use OD_IO_t instead OD_stream_t.
- OD_getSub(), argument subEntry is optional.
- Change return value of OD_extensionIO_init() to ODR_t.
2020-12-02 16:44:31 +01:00
Janez
a6ce313387 New Object Dictionary project file, etc. Remove old OD. Update doc. 2020-11-28 12:17:48 +01:00
Janez
5a14e91834 Set CANopenNode version V4.0
Skip V3.0, because there exists some old version numbering from SouceForge.
V3.00 exists also in old CO_OD.c. Use 4.0 to avoid confusion.
2020-10-29 09:58:26 +01:00
Janez
da850252bd Set CANopenNode version V3.0
Added macros CO_VERSION_MAJOR and CO_VERSION_MINOR into driver.h
2020-10-29 09:38:21 +01:00
Janez
ee1d8d0c81 Restore CO_CONFIG_HB_CONS_CALLBACK_CHANGE option, same as #241 2020-10-26 19:05:26 +01:00
Janez
ace840fa6c Fix ODinterface, basic tests passed. 2020-10-26 18:16:00 +01:00
Janez
0e317dddf3 Add CO_errinfo() into CO_driver.h and driver_targets.
Add additional error info for 'CO_ERROR_OD_PARAMETERS'.
2020-10-26 18:05:47 +01:00
Janez
cf9fb2a547 Some updates in OD interface.
It matches newly generated OD.h and OD.c files from libedssharp
2020-10-21 11:29:03 +02:00
Janez
f73025ef65 CANopenNode V2.0 pre-release 2020-10-07 17:50:25 +02:00
Janez
7a43f98f24 Configuration macros updated 2020-10-07 13:47:07 +02:00
Janez
1385c763aa small fix 2020-09-29 12:26:26 +02:00
oto313
ffa92310a7
Update CO_HBconsumer.c (#229)
When current node is CO_HBconsumer_UNCONFIGURED then other nodes are skipped
2020-09-29 09:50:18 +02:00
Wilkins White
28925a4e3c
Add CO_SYNCsend() (#225)
* add CO_SYNCsend function

* change return type of CO_TPDOsend
2020-09-29 09:24:21 +02:00
Carsten Frank
87b293b3e6
Do ErrorReset of SYNC timeout (#220) 2020-09-29 09:19:06 +02:00
Janez
6cdc70fb4e Object dictionary interface, preview updated. 2020-09-19 09:58:49 +02:00
Janez
9446aa5792 CO_TIME.c can be disabled 2020-09-14 16:49:48 +02:00
Janez
4b855d04f7 CO_TIME.c can be disabled 2020-09-14 16:45:05 +02:00
Janez
a528eb1669 Better organised configuration macros (CO_config.h):
- rearranged and better documented
 - default values moved from CO_driver.h into appropriate files
 - rearranged also in CO_driver_target.h files
 - parts of the stack or whole objects can be disabled.
 - configuration is verified for depencies

Additional:
 - renamed some members of CO_Default_CAN_ID_t
 - moved helpers CO_setUint32() etc from CO_SDOserver.h into CO_driver.h.
 - change wrong CO_ERROR_PARAMETERS to CO_ERROR_ILLEGAL_ARGUMENT.
 - renamed CO_ERROR_PARAMETERS to CO_ERROR_OD_PARAMETERS
2020-09-14 15:50:21 +02:00
Miles Simpson
2c5d685343
Differentiate between SDO_C states so state can be determined in a worker thread when passed a CO_SDOclient_t pointer (#218)
Added #defines for SDO state flags for use by applications

Changed CO_SDO_ST_ABORT to next sequential value
2020-08-11 11:55:12 +02:00
Janez
8783bfff05 use crc16-ccitt.h in CO_fifo.c
It was duplicated.
Commited also some small changes + ODinterface
2020-08-04 23:39:25 +02:00
Janez
2d07d7af17 OD interface: remove "lowLimit" and "highLimit"
Too complicated to implement and litmited usefulness. IO extension is better.
2020-07-25 13:17:01 +02:00
Janez
748086a751 Move enumerator CO_SDOclient_return_t to CO_SDO_return_t
(from CO_SDOclient.h into CO_SDOserver.h)
2020-07-24 10:10:05 +02:00
Janez
1410a20e95 Replace CO_memcpySwap4() 2020-07-23 13:37:50 +02:00
Janez
756c76d08a Added information about XML device description 2020-07-23 07:34:28 +02:00
Norcio
03df5f65b8
fix for missing int cast which cause compilation warning/error when ctype,__cplusplus and esp32 is used (#212)
error: array subscript has type 'char' [-Werror=char-subscripts]
2020-07-22 07:31:56 +02:00
Janez
f68e9dade7 Fix previous commit 2020-07-14 16:28:32 +02:00
Janez
1f92aee85a SDO: fix broken block download #210
by lukegluke, same as commit in v1.3-master
2020-07-13 15:12:40 +02:00
Janez
d98fb635f5 Added CO_ODinterface 2020-07-13 14:08:16 +02:00
Janez
e79ed1709e Update documentation 2020-07-13 14:07:26 +02:00
Janez
035da160b5 SDO: fix to always check if buffer is empty before freeing it #204
Before this patch SDO queue process pointer could overrun receive pointer on receiving NMT stop command during active SDO communication.
This fix is applied to 'master' and 'v1.3-master' branches.
2020-07-01 09:44:18 +02:00
Janez
9dd36aa649 Manual merge #202:
- fix conflicts in CO_SRDO.h and CO_SRDO.c
- Add configs for GFC & SRDO for CO_driver.h and not for socketCAN
- Fix doxygen for CO_gateway_ascii
2020-07-01 09:02:40 +02:00
Freddie Chopin
7c13199a1a Fix all possible warnings about unused timerNext_us argument 2020-06-26 11:56:46 +02:00
gotocoffee
0f7b3e2d17
CANopen Safety (SRDO according to DIN EN 50325-5:2016) (#196)
* CANopen Safety (SRDO according to DIN EN 50325-5:2016)

* GFC code and docs

* clang-format on GFC

Co-authored-by: rg1 <r.gruening@miunske.com>
2020-06-22 10:14:14 +02:00
Janez
aed6a472d4 LSS led flickering fix. 2020-06-14 12:35:42 +02:00
Janez
ca452c47cc CO_driver interface: remove Emergency object dependency for reporting CAN
errors, use CANerrorStatus own variable instead. Emergency object updated.
2020-06-13 14:06:35 +02:00
Janez
e1c7e2dbfa Add fifo queue for SDO received messages to fix possible drops
Same as pr #174 in v1.3-master
2020-06-11 10:33:03 +02:00
Paolo Teti
6551233406
GCC 10: Fix dereference of NULL warning (#191)
GCC 10 static analyzer (-fanalyzer) warn about possible dereference
of NULL ‘ext’ on 'ext->pODFunc'.

This patch adds a guard on 'ext' to fix the issue.
2020-06-09 17:11:09 +02:00
Janez
dd1677b5bc Integrate LSS slave into CANopenNode more directly.
- CO_LSSslave: move expensive code from CAN receive (interrupt) to mainline
  CO_LSSslave_process() function.
- LSS slave now runs in parallel to other CANopen objects.
- LSS slave and master can run both on same device.
- LSS slave, LSS master and gateway-ascii(CiA309) LSS functions tested.
- LSSusage.md updated.
2020-06-09 14:55:07 +02:00
Janez
bd3326fed9 Make own file for CANopen status LED diodesLED indicator indication
(CiA303-3) moved from NMT into own files. Now fully comply to standard.
2020-06-05 18:02:26 +02:00
Janez
229b5c5fd3 Change optional arguments in CO_RPDO_init(), CO_TPDO_init(), CO_GTWA_init() 2020-05-31 22:08:36 +02:00
Janez
ae220f9115 Configuration for LSS updated. 2020-05-29 09:56:05 +02:00
Janez
cb9b2cce42 Add printout of message log from CANopen gateway-ascii (non-standard). 2020-05-29 07:36:23 +02:00
Janez
f41069561a Make SDO client and NMT master optional in gateway_ascii 2020-05-28 16:40:21 +02:00
Paolo Teti
6db813a998
TIME: fix round up conversion from usec to msec (#189)
Use standard idiom for integer rounding up.

Signed-off-by: Paolo Teti <paolo.teti@gmail.com>
2020-05-27 13:48:16 +02:00
Paolo Teti
6c16680d02
Use memcpy() and memset() where possible (#188)
* LLSMaster: replace explicit array element copy with memcpy()

Replace explicit array element copy with memcpy()

Signed-off-by: Paolo Teti <paolo.teti@gmail.com>

* SDO server: copy and zeroize arrays using memcpy() and memset()

* Replace array elements copy with memcpy().
* Clear response buffer using memset()

Signed-off-by: Paolo Teti <paolo.teti@gmail.com>
2020-05-27 13:42:50 +02:00
Janez
c1a30b8a03 Some style corrections
- add CO_fifo_st enumerator for use in CO_fifo_cpyTok2xx functions.
- 309/CO_gateway_ascii: add x8 to x64 nonstandard data types
- example compiles now
- Fix "unused argument" warnings in socketCAN
2020-05-15 15:52:22 +02:00
Freddie Chopin
288f8c603f
Fix fifo include (#184)
* Include CO_fifo.h in CO_SDOclient.h in all cases

Struct CO_SDOclient_t has CO_fifo_t member no matter what configuration
is set, so the header is always required. Without this change the build
fails when CO_CONFIG_SDO_CLI_SEGMENTED is not enabled.

* Fix minor copy-paste errors in CO_config.h comments
2020-05-14 16:24:04 +02:00
Freddie Chopin
d272934647
Fix new -Wextra warnings (#185)
* Fix new "unused argument" warnings

* Fix "variable may be used uninitialized" in CO_process_SYNC()

With enabled optimization compiler reports:

CANopen.c: In function ‘CO_process_SYNC’:
CANopen.c:890:12: warning: ‘syncWas’ may be used uninitialized in this
function [-Wmaybe-uninitialized]
  890 |     return syncWas;
      |            ^~~~~~~
2020-05-14 16:23:02 +02:00
Janez
b5bfeec42a Added CANopen gateway-ascii command interface according to CiA309-3 as a
microcontroller independent module.
It includes NMT master, LSS master and SDO client interface.
Interface is non-blocking, it is added to mainline.
Example for Linux stdio and socket is included.

Added CO_fifo.h/c for fifo data buffer, used with rewritten SDO client, etc

SDO client is rewritten. Now includes r/w fifo interface to transfer data.

doc/gettingStarted.md is updated.
2020-05-12 18:11:43 +02:00
Paolo Teti
61fc785fab
CO_SYNC_process: use enums instead of uint8_t (#182)
Replace hard-coded values with enums and explicit manage all enumeration
values in CO_process_SYNC() to avoid warnings like this:

CANopen.c:837:5: warning: enumeration value ‘CO_SYNC_NONE’ not handled in switch [-Wswitch]
  837 |     switch (sync_process) {
      |     ^~~~~~
2020-05-12 17:35:16 +02:00
Janez
d9c16ae763
Merge pull request #183 from DISTORTEC/even-moar-callbacks
Add CO_TIME_initCallbackPre(), convert {T,R}PDO_CALLS_EXTENSION to config options
2020-05-12 17:30:59 +02:00
Freddie Chopin
0048cb52c7
Fix pointer bug in CO_OD_getFlagsPointer() (#181)
Function did not check whether the object had any flags assigned. It
makes no difference for objects with no subindexes, because then the
function will return NULL anyway. But is subIndex argument is not zero,
then the function calculates addresses of flags as offsets from NULL.
For example, for an object with no flags assigned, when subIndex == 5,
the function would return 5 as the address instead of the expected NULL.
2020-05-12 17:24:06 +02:00
Freddie Chopin
b4b0fe069f Convert {T,R}PDO_CALLS_EXTENSION to CO_CONFIG_{T,R}PDO_CALLS_EXTENSION
User can now enable extension callbacks in RPDO/TPDO handling paths
simply by configuration flags instead of modifying sources or by passing
the defines directly to the compiler.
2020-05-06 18:22:50 +02:00
Freddie Chopin
9b8a296fb7 Add CO_TIME_initCallbackPre() for received TIME messages
This optional mechanism allows to immediatelly wake the thread that
processes TIME, without waiting for its next tick.
2020-05-06 18:08:45 +02:00
Freddie Chopin
495f827d37 Fix minor typo/edit mistakes in CHANGELOG.md and CO_config.h 2020-05-06 18:00:28 +02:00
Freddie Chopin
aa6075b3c8
Add CO_..._initCallbackPre() for RPDO and SYNC (#178)
* Merge two parts of CO_PDO_receive() into single common code

* Add CO_RPDO_initCallbackPre() for received RPDO messages

This optional mechanism allows to immediatelly wake the thread that
processes RPDO, without waiting for its next tick.

* Add CO_SYNC_initCallbackPre() for received SYNC messages

This optional mechanism allows to immediatelly wake the thread that
processes SYNC, without waiting for its next tick.
2020-05-05 13:23:26 +02:00
Freddie Chopin
4c3011d34a
Replace all memcpy/memset-like functions with standard <string.h> functions (#175)
* Use standard memcpy() instead of CO_memcpy()

* Remove CO_memcpy()

* Use standard memset() instead of CO_memset()

* Remove CO_memset()

* Move helper functions from CO_SDOserver.c to header and make them inline

* Implement CO_getUint16() with memcpy()

* Implement CO_getUint32() with memcpy()

* Implement CO_setUint16() with memcpy()

* Implement CO_setUint32() with memcpy()

* Define memcpy() as CO_memcpySwapX() for little-endian systems

* Fix several writes past the buffer due to hardcoded sizes

Use more "generic" sizes (via sizeof()) instead of hardcoded number in
all calls to memset() to avoid 1-byte errors which result in writes past
the buffer, for example:

memset(&LSSslave->TXbuff->data[5], 0, 4);
in CO_LSSslave_serviceInquire()

memset(&LSSmaster->TXbuff->data[6], 0, 3);
in CO_LSSmaster_switchStateSelectInitiate()

* Use "generic" size in calls to memcpy() where possible

* Remove CO_bytes_t

This type was used only for CO_{get,set}Uint{16,32}().
2020-05-04 11:22:32 +02:00
Janez
5a2a1e85cf Update configuration macros. SDO state machine preview. 2020-04-29 13:12:07 +02:00
Janez
5bb2d16323 fix SDO block download process continuity after sequence breaks
This is the same as pull request #171, but applied to split-driver branch.
Original author: Oleg <ev.mipt@gmail.com>

Now additional state CO_SDO_ST_DOWNLOAD_BL_SUB_RESP_2 is used to send response without resetting SDO sequence.
Refactoring timeout halding logic in sub-block transfer.
Also add missed unsigned indicators for several constants.

issue #170
2020-04-07 09:41:00 +02:00
Janez
43f86073ee Minor corrections in documentation. 2020-04-03 11:43:14 +02:00
Janez
ffd5027cb2 Make SYNC optional in TPDO and RPDO. 2020-03-20 18:47:16 +01:00
Janez
6e28914ca9 Make calculation of timerNext_us optional. 2020-03-20 16:44:37 +01:00
Janez
3fd799f919 Heartbeat is send immediately after NMT state changes. 2020-03-19 18:59:58 +01:00
Janez
c88194e813 Add Stack configuration macros to most of CANopenNode objects.
Add CO_NMT_initCallbackPre()
2020-03-19 18:07:23 +01:00
Janez
d9c44c69d1 Change non-descriptive CO_***_initCallback() into CO_***_initCallbackPre().
Change CO_NMT_initCallback() into CO_NMT_initCallbackChange().
Change type of NMT->operatingState from uint8_t into enum CO_NMT_internalState_t.
2020-03-18 23:19:29 +01:00
Janez
b8e821d0dd Add CO_NMT_UNKNOWN state for Heartbeat consumer. 2020-03-18 21:46:34 +01:00
Janez
794c0f903a Added file CO_config.h for stack configuration. Added CO_HBconsumer_initCallback() 2020-03-18 21:06:15 +01:00
Janez
0b2476ec95 Fix timeout and "timerNext_us" in SDO server and client. 2020-03-18 10:12:53 +01:00
Janez
18bc8d4313 HBconsumer: add CO_HBconsumer_initCallbackNmtChanged(), callbaks optional
- Make HBconsumer callbacks optional via CO_CONFIG_HB_CONS_CALLBACKS
  definition.
- Add additional callback CO_HBconsumer_initCallbackNmtChanged()
2020-03-13 16:05:27 +01:00
Janez
1ce3732e60 SocketCAN: change CO_DRIVER_MULTI_INTERFACE and CO_DRIVER_ERROR_REPORTING
- Replace macro USE_EMERGENCY_OBJECT with CO_DRIVER_USE_EMERGENCY 1
- Now define sets macro to 0 or 1. It is easier to set custom value.
2020-03-12 16:20:40 +01:00
Janez
2f204a0c71 Verify return value from CO_CANrxBufferInit() and CO_CANtxBufferInit(). 2020-03-12 12:18:05 +01:00
Janez
1624b7443d Ignore sync message in Emergency receive function CO_EM_receive(). 2020-03-12 10:42:19 +01:00
Janez
fb2274fc9f socketCAN driver, CO_CANrxBufferInit(): remove check COB ID already used.
If two or more CANrx buffers have the same _ident_, then buffer with
lowest _index_ has precedence and other CANrx buffers will be ignored.
2020-03-11 17:48:48 +01:00
Janez
42f2554f2f Add emergency receive callback also for own emergency messages. 2020-03-11 17:44:33 +01:00
Janez
02e2cc5860 Stack configuration added do CO_driver.h
Change macro CO_USE_LEDS -> CO_CONFIG_NMT_LEDS 1
Change macro CO_SDO_BUFFER_SIZE -> CO_CONFIG_SDO_BUFFER_SIZE
2020-03-07 16:26:52 +01:00
Janez
3fc79b807e Remove pFunctSignal from mainline processing functions. Use timerNext_us.
Interface to CO_SDOclientDownloadInitiate and CO_SDOclientUploadInitiate
changed (added optional *timerNext_us argument). Little corrections in
documentation for CO_SDOclient.h
2020-03-07 13:32:14 +01:00
Janez
78487ba89f Clarify EM, SDOserver, SDOclient and LSSmaster callback functions.
callback functions called also from SDO_blockTransferInProgress.
Clarify timerNext_us parameter to CO_process() function.
2020-02-27 16:43:27 +01:00
Janez
8fb48173c6 Add CO_CANopenInitCallback() into CANopen.h/.c.
Change CO_*_initCallback() functions - add 'void *object' argument.
2020-02-27 13:09:48 +01:00
Janez
2fa91d2c69 Fixed:
BUG in CO_HBconsumer.c #168
Misleading Comments in CO_SDO.h #169
2020-02-24 09:42:20 +01:00
Janez
e55674bf6f Documentation updated, ChangeLog deviceSupport and gettingStarted added.
CANopen.h fixed.
2020-02-15 16:35:39 +01:00
Janez
ae48e57c33 CANopen.h/.c revision.
- example/main.c updated to microsecond time base.
- NMT master moved from CANopen.h/.c into 301/CO_NMT_Heartbeat.h/.c.
- CANopen.h/.c files revised, changes in interface, compare example/main.c.
- Removed CO_init() from CANopen.h/.c. Use separate functions instead.
- CO_USE_GLOBALS and global definitions removed from CANopen.c.
- CO_USE_OWN_CRC16 removed from CANopen.c. Use CO_driver_target.h.
2020-02-06 00:15:54 +01:00
Janez
62ffc7c9f5 Drivers removed from stack, directory structure rearranged.
- Change log added to README.
- Doxygen documentation updated.
2020-02-05 10:52:56 +01:00