MCPcopy Create free account
hub / github.com/CANopenNode/CANopenNode / CO_LSSmaster_IdentifyFastscan

Function CO_LSSmaster_IdentifyFastscan

305/CO_LSSmaster.c:841–963  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

839}
840
841CO_LSSmaster_return_t
842CO_LSSmaster_IdentifyFastscan(CO_LSSmaster_t* LSSmaster, uint32_t timeDifference_us,
843 CO_LSSmaster_fastscan_t* fastscan) {
844 uint8_t i;
845 uint8_t count;
846 CO_LSSmaster_return_t ret = CO_LSSmaster_INVALID_STATE;
847 uint8_t next;
848
849 /* parameter validation */
850 if ((LSSmaster == NULL) || (fastscan == NULL)) {
851 return CO_LSSmaster_ILLEGAL_ARGUMENT;
852 }
853 if (fastscan->scan[0] == CO_LSSmaster_FS_SKIP) {
854 /* vendor ID scan cannot be skipped */
855 return CO_LSSmaster_ILLEGAL_ARGUMENT;
856 }
857 count = 0;
858 for (i = 0; i < (sizeof(fastscan->scan) / sizeof(fastscan->scan[0])); i++) {
859 if (fastscan->scan[i] == CO_LSSmaster_FS_SKIP) {
860 count++;
861 }
862 if (count > 2U) {
863 /* Node selection needs the Vendor ID and at least one other value */
864 return CO_LSSmaster_ILLEGAL_ARGUMENT;
865 }
866 }
867
868 /* state machine validation */
869 if ((LSSmaster->state != CO_LSSmaster_STATE_WAITING)
870 || ((LSSmaster->command != CO_LSSmaster_COMMAND_WAITING)
871 && (LSSmaster->command != CO_LSSmaster_COMMAND_IDENTIFY_FASTSCAN))) {
872 /* state machine not ready, other command is already processed */
873 return CO_LSSmaster_INVALID_STATE;
874 }
875
876 /* evaluate LSS state machine */
877 if (LSSmaster->command == CO_LSSmaster_COMMAND_WAITING) {
878 /* start fastscan */
879 LSSmaster->command = CO_LSSmaster_COMMAND_IDENTIFY_FASTSCAN;
880
881 /* check if any nodes are waiting, if yes fastscan is reset */
882 LSSmaster->fsState = CO_LSSmaster_FS_STATE_CHECK;
883 CO_LSSmaster_FsSendMsg(LSSmaster, 0, CO_LSS_FASTSCAN_CONFIRM, 0, 0);
884
885 return CO_LSSmaster_WAIT_SLAVE;
886 } else {
887 /* continue with evaluating fastscan state machine */
888 }
889
890 /*
891 * evaluate fastscan state machine. The state machine is evaluated as following
892 * - check for non-configured nodes
893 * - scan for vendor ID
894 * - verify vendor ID, switch node state
895 * - scan for product code
896 * - verify product code, switch node state
897 * - scan for revision number
898 * - verify revision number, switch node state

Callers 1

CO_gateway_ascii.cFile · 0.85

Calls 7

CO_LSSmaster_FsSendMsgFunction · 0.85
CO_LSSmaster_FsCheckWaitFunction · 0.85
CO_LSSmaster_FsScanWaitFunction · 0.85

Tested by

no test coverage detected