-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Issues with format of the data in CMessage class #10
Comments
Hello,
You code seems ok. What is your network ? How do you configure the CAN module ? Is it alone in the network ? In normal mode, a CAN controller do not receive the frames it sends.
Pierre
… Le 16 nov. 2023 à 13:57, Marcel307 ***@***.***> a écrit :
Hi,
I am a bit new to this library and CAN in general. I have an ADXL357 accelerometer that give me 3 axis, each containing 8 Bytes of data, becausse the values are on type double. Now just for a small test I want to sent out each iteration one axis, in my case z. But it seems like the append() is setting the ok variable to false, not sending out any kind of data. On startup there is weird behaviour, because it tells me that the ok Variable is true, but the number of SentFrameCounts is not progressing more than just to the value of one.
So I am asking myself what the problem might be?
Snipplet out of the main File. This whole snipplet is written within a for-loop function iterating through the different sensors.
CANMessage frame;
if(gSentFrameCountESP32 < MESSAGE_COUNT)
{
frame.id = 0x001F;
frame.len = 8;
frame.data_s64 = z;
frame.rtr = false;
frame.ext = false;
const bool ok = ACAN_ESP32::can.tryToSend(frame);
Serial.print("The Value of the ok variable is: ");
Serial.println(ok);
if(ok)
{
gSentFrameCountESP32 =+ 1;
}
}
while(ACAN_ESP32::can.receive(frame))
{
gReceivedFrameCountESP32 =+ 1;
}
Serial.print("Numbers of packets sent: ");
Serial.print(gSentFrameCountESP32);
}
—
Reply to this email directly, view it on GitHub <#10>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AEWKZVACYXKVQPHNC5U2NDTYEYESRAVCNFSM6AAAAAA7ODSOK6VHI2DSMVQWIX3LMV43ASLTON2WKOZRHE4TMOBQGEYDGOI>.
You are receiving this because you are subscribed to this thread.
|
No the CAN Controller the Module is not alone in the Node. I am also using a another ESP32 and a another Module that supports CAN. Important to note is that the other ESP32 is using a another CAN lib. Before I testet this setup and it worked so that is confusing. And yes it is setup in normal mode.
Marcel |
Hello there, Marcel |
Hello,
The CANMessage class is defined in the CANMessage.h file :
class CANMessage {
public : uint32_t id = 0 ; // Frame identifier
public : bool ext = false ; // false -> standard frame, true -> extended frame
public : bool rtr = false ; // false -> data frame, true -> remote frame
public : uint8_t idx = 0 ; // This field is used by the driver
public : uint8_t len = 0 ; // Length of data (0 ... 8)
public : union {
uint64_t data64 ; // Caution: subject to endianness
int64_t data_s64 ; // Caution: subject to endianness
uint32_t data32 [2] ; // Caution: subject to endianness
int32_t data_s32 [2] ; // Caution: subject to endianness
float dataFloat [2] ; // Caution: subject to endianness
uint16_t data16 [4] ; // Caution: subject to endianness
int16_t data_s16 [4] ; // Caution: subject to endianness
int8_t data_s8 [8] ;
uint8_t data [8] = {0, 0, 0, 0, 0, 0, 0, 0} ;
} ;
} ;
If you want to add double, just add a field to the union :
public : union {
uint64_t data64 ; // Caution: subject to endianness
double data_double ; // Caution: subject to endianness
int64_t data_s64 ; // Caution: subject to endianness
uint32_t data32 [2] ; // Caution: subject to endianness
int32_t data_s32 [2] ; // Caution: subject to endianness
float dataFloat [2] ; // Caution: subject to endianness
uint16_t data16 [4] ; // Caution: subject to endianness
int16_t data_s16 [4] ; // Caution: subject to endianness
int8_t data_s8 [8] ;
uint8_t data [8] = {0, 0, 0, 0, 0, 0, 0, 0} ;
} ;
For setting a double value :
CANMessage message ;
…
message.data_double = a double value ;
Best regards,
Pierre
… Le 21 nov. 2023 à 15:40, Marcel307 ***@***.***> a écrit :
Hello there,
I have resolved my issues mentioned before. But now I have a other question. I want to send out the accel data of type double. If I want to send out the double data or add the type to the CANMessage class the frame will not be sent. Why is that?
Marcel
—
Reply to this email directly, view it on GitHub <#10 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AEWKZVBQ47ISLMQYDMLDJWTYFS4NTAVCNFSM6AAAAAA7ODSOK6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRRGA2TGMJQGQ>.
You are receiving this because you commented.
|
Hi,
I am a bit new to this library and CAN in general. I have an ADXL357 accelerometer that give me 3 axis, each containing 8 Bytes of data, becausse the values are on type double. Now just for a small test I want to sent out each iteration one axis, in my case z. But it seems like the append() is setting the ok variable to false, not sending out any kind of data. On startup there is weird behaviour, because it tells me that the ok Variable is true, but the number of SentFrameCounts is not progressing more than just to the value of one.
So I am asking myself what the problem might be?
Snipplet out of the main File. This whole snipplet is written within a for-loop function iterating through the different sensors.
The text was updated successfully, but these errors were encountered: