Skip to content

Commit 02110df

Browse files
committed
Update message id for each message send
1 parent 805031e commit 02110df

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

hal/transport/CAN/MyTransportCAN.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ bool canInitialized=false;
2626
long unsigned int rxId;
2727
unsigned char len = 0;
2828
unsigned char rxBuf[8];
29-
30-
3129
unsigned char _nodeId;
30+
uint8_t message_id =0;
3231

3332
//buffer element
3433
typedef struct {
@@ -143,14 +142,10 @@ bool transportSend(const uint8_t to, const void* data, const uint8_t len, const
143142
}
144143
//set left most bit to 1 as this indicates extended frame
145144
uint8_t h1 = 0x80;
146-
//TODO increment msg_id for new message.
147-
// uint8_t msg_id = 7;
148-
//add msg_id. 7 is maximum allowed value (3bits)
149-
// h1 += (msg_id & 0x07);
150-
// if (!noACK) {
151-
//set require ACK bit - to be implemented
152-
// h1 = h1 | 0x08;
153-
// }
145+
//increment msg_id for new message.
146+
h1+=message_id;
147+
message_id++;
148+
message_id=(message_id & 0x07);
154149

155150
//set total number of frames
156151
uint8_t h2 = noOfFrames;
@@ -208,7 +203,7 @@ bool transportDataAvailable(void)
208203
long unsigned int currentPart=(rxId & 0x000F0000)>>16;
209204
long unsigned int totalPartCount=(rxId & 0x00F00000)>>20;
210205
long unsigned int messageId=(rxId & 0x07000000)>>24;
211-
CAN_DEBUG(PSTR("CAN:RCV:CANH=%" PRIu32 ",FROM=%" PRIu8 ",TO=%" PRIu8 ",CURR=%" PRIu8 ",TOTAL=%" PRIu8 ",ID=%" PRIu8 "\n"), rxId, from, to, currentPart,totalPartCount,messageId);
206+
CAN_DEBUG(PSTR("CAN:RCV:CANH=%" PRIu32 ",FROM=%" PRIu32 ",TO=%" PRIu32 ",CURR=%" PRIu32 ",TOTAL=%" PRIu32 ",ID=%" PRIu32 "\n"), rxId, from, to, currentPart,totalPartCount,messageId);
212207

213208
uint8_t slot;
214209
if(currentPart==0){

0 commit comments

Comments
 (0)