C++ how to assign a received frame in a variable
-
- Posts: 59
- Joined: Tue 3. Aug 2021, 23:34
C++ how to assign a received frame in a variable
Hello,
Testing my c++ code, offline...
Without calls to pcanbasic methods, I need to test my other methods, and I'd like to test with this default received frame.
can_frame = [1002404000a005000000170ff230d181400];
But doesn t work!!
Brackets doesn't seems to be the right method?!!
Just need one ex of this variable alimentation.
Thanks all
Vincent
Testing my c++ code, offline...
Without calls to pcanbasic methods, I need to test my other methods, and I'd like to test with this default received frame.
can_frame = [1002404000a005000000170ff230d181400];
But doesn t work!!
Brackets doesn't seems to be the right method?!!
Just need one ex of this variable alimentation.
Thanks all
Vincent
-
- Sales & Support
- Posts: 977
- Joined: Fri 20. Sep 2019, 13:31
Re: C++ how to assign a received frame in a variable
Hello,
Please use the structure as defined by PCANBasic: Also you should test with an hardware active,
PCANBasic works closely with the driver, which will require
an active hardware to function as intended.
Best Regards
Marvin
Please use the structure as defined by PCANBasic: Also you should test with an hardware active,
PCANBasic works closely with the driver, which will require
an active hardware to function as intended.
Best Regards
Marvin
---
Marvin Heidemann
PEAK-Support Team
Marvin Heidemann
PEAK-Support Team
-
- Posts: 59
- Joined: Tue 3. Aug 2021, 23:34
Re: C++ how to assign a received frame in a variable
Hey, Marvin,
I have this process in my code.
My question is :
What is c++ type of requested msg variable?
Is it data[64]?
Can I request 3rd byte as :
Int byte3 = msg.DATA[2]
from a RECEIVED CANFD message
I have this process in my code.
My question is :
What is c++ type of requested msg variable?
Is it data[64]?
Can I request 3rd byte as :
Int byte3 = msg.DATA[2]
from a RECEIVED CANFD message
-
- Sales & Support
- Posts: 977
- Joined: Fri 20. Sep 2019, 13:31
Re: C++ how to assign a received frame in a variable
Hello,
The struct for messages is the same regardless of their direction,
see the PCANbasic.h file:
You can assign the returned byte from the array to an Int, but you'll
have to cast the byte to int.
The struct for messages is the same regardless of their direction,
see the PCANbasic.h file:
Code: Select all
////////////////////////////////////////////////////////////
// Structure definitions
////////////////////////////////////////////////////////////
// Represents a PCAN message
//
typedef struct tagTPCANMsg
{
DWORD ID; // 11/29-bit message identifier
TPCANMessageType MSGTYPE; // Type of the message
BYTE LEN; // Data Length Code of the message (0..8)
BYTE DATA[8]; // Data of the message (DATA[0]..DATA[7])
} TPCANMsg;
// Represents a timestamp of a received PCAN message
// Total Microseconds = micros + 1000 * millis + 0x100000000 * 1000 * millis_overflow
//
typedef struct tagTPCANTimestamp
{
DWORD millis; // Base-value: milliseconds: 0.. 2^32-1
WORD millis_overflow; // Roll-arounds of millis
WORD micros; // Microseconds: 0..999
} TPCANTimestamp;
// Represents a PCAN message from a FD capable hardware
//
typedef struct tagTPCANMsgFD
{
DWORD ID; // 11/29-bit message identifier
TPCANMessageType MSGTYPE; // Type of the message
BYTE DLC; // Data Length Code of the message (0..15)
BYTE DATA[64]; // Data of the message (DATA[0]..DATA[63])
} TPCANMsgFD;
have to cast the byte to int.
---
Marvin Heidemann
PEAK-Support Team
Marvin Heidemann
PEAK-Support Team
-
- Posts: 59
- Joined: Tue 3. Aug 2021, 23:34
Re: C++ how to assign a received frame in a variable
Perfect. Thanks Marvin.
You can close.
You can close.