35 struct timespec tspec;
38 clock_gettime(CLOCK_REALTIME, &tspec);
39 tstruct = localtime(&tspec.tv_sec);
42 *tm->
epochTimeBaseMs = ((uint64_t) (tspec.tv_sec - tstruct->tm_sec)) * 1000;
49 static CO_SDO_abortCode_t CO_ODF_time(CO_ODF_arg_t *ODF_arg) {
51 CO_SDO_abortCode_t
ret = CO_SDO_AB_NONE;
56 if(ODF_arg->reading) {
59 if(ODF_arg->subIndex == 1){
64 timeString = ctime(&t);
66 strncpy((
char*) ODF_arg->data, timeString, ODF_arg->dataLength);
67 ODF_arg->data[ODF_arg->dataLength - 1] = 0;
71 if(ODF_arg->subIndex == 3) {
79 ret = CO_SDO_AB_INVALID_VALUE;
92 uint64_t *epochTimeBaseMs,
100 if(*epochTimeBaseMs == 0) {
104 CO_OD_configure(SDO, idx_OD_time, CO_ODF_time, (
void*)tm, 0, 0);
void CO_time_init(CO_time_t *tm, CO_SDO_t *SDO, uint64_t *epochTimeBaseMs, uint32_t *epochTimeOffsetMs, uint16_t idx_OD_time)
void CO_time_process(CO_time_t *tm)
uint64_t * epochTimeBaseMs
char ret[STRING_BUFFER_SIZE]
Time object, usable for timestamping - Defined in CANOpen code.
uint32_t * epochTimeOffsetMs