Read works!

This commit is contained in:
Anders Sandstrom
2021-03-02 13:10:15 +01:00
parent 18153ee694
commit 9e729db05e
2 changed files with 14 additions and 14 deletions

View File

@@ -60,7 +60,7 @@ int canConstruct(char *configStr)
alreadyLoaded = 1;
// create SocketCAN object and register data callback
lastConfStr = strdup(configStr);
createSocketCAN(configStr);
return createSocketCAN(configStr);
/* int nbytes;
struct sockaddr_can addr;
@@ -95,7 +95,7 @@ int canConstruct(char *configStr)
deleteSocketCANbytes);
*/
return 0;
//return 0;
}
/** Optional function.

View File

@@ -24,10 +24,11 @@
#include "ecmcAsynPortDriverUtils.h"
#include "epicsThread.h"
// New data callback from ecmc
static int printMissingObjError = 1;
// Start worker for socket read()
void f_worker_read(void *obj) {
if(!obj) {
printf("%s/%s:%d: Error: Worker read thread ecmcSocketCAN object NULL..\n",
@@ -160,16 +161,17 @@ void ecmcSocketCAN::doReadWorker() {
}
// Wait for new CAN frame
read(socketId_, &rxmsg_, sizeof(rxmsg_));
printf("\n0x%02X", rxmsg_.can_id);
printf(" [%d]", rxmsg_.can_dlc);
for(int i=0; i<rxmsg_.can_dlc; i++ ) {
printf(" 0x%02X", rxmsg_.data[i]);
read(socketId_, &rxmsg_, sizeof(rxmsg_));
if(cfgDbgMode_) {
// Simulate candump printout
printf("\n0x%02X", rxmsg_.can_id);
printf(" [%d]", rxmsg_.can_dlc);
for(int i=0; i<rxmsg_.can_dlc; i++ ) {
printf(" 0x%02X", rxmsg_.data[i]);
}
}
}
}
// Test can write function
@@ -383,8 +385,6 @@ asynStatus ecmcSocketCAN::readInt32(asynUser *pasynUser, epicsInt32 *value) {
return asynSuccess;
}
asynStatus ecmcSocketCAN::readInt8Array(asynUser *pasynUser, epicsInt8 *value,
size_t nElements, size_t *nIn) {
int function = pasynUser->reason;
@@ -405,7 +405,7 @@ asynStatus ecmcSocketCAN::readInt8Array(asynUser *pasynUser, epicsInt8 *value,
asynStatus ecmcSocketCAN::readFloat64(asynUser *pasynUser, epicsFloat64 *value) {
int function = pasynUser->reason;
/* if( function == asynSRateId_ ) {
/*if( function == asynSRateId_ ) {
*value = cfgDataSampleRateHz_;
return asynSuccess;
}