Hello the team.
Is it possible to send many frames same times ?
ex : send a request on id 1, 2, 3 on PCAN_DEV1, and 4, 5, 6 on PCAN_DEV2
then read all frames same time.
In fact, I need a usleep(200) between query frame and it read. And I need it for 12 ID's
This parallelism could make me use only one usleep(200) between the full query and the full read ?!
If yes, any example ?
Thanks a lot the team.
ps : peak 4canM2 is a really nice canfd board !
read or send multiple frame same time (peak 4canM2) c++
-
- Posts: 59
- Joined: Tue 3. Aug 2021, 23:34
Re: read or send multiple frame same time (peak 4canM2) c++
Hello,
yes, you could send and read multiple frames at the same time. However, the speed the frames could be send on the CAN bus system is depending on your bitrate used on your CAN system.
regards
Michael
yes, you could send and read multiple frames at the same time. However, the speed the frames could be send on the CAN bus system is depending on your bitrate used on your CAN system.
regards
Michael
-
- Posts: 59
- Joined: Tue 3. Aug 2021, 23:34
Re: read or send multiple frame same time (peak 4canM2) c++
Hey, Mr Maidhof.
Well, I'm trying to have frames transmissions as solid as possible.
- Using PCAN-M.2 board with 4 ports, on up xtreme i7.
- ubuntu 20.04 RT
- TPCANBitrateFD BitrateFD = (char*) "f_clock_mhz = 80, nom_brp = 1, nom_tseg1 = 50, nom_tseg2 = 29, nom_sjw = 10, data_brp = 1, data_tseg1 = 8, data_tseg2 = 7, data_sjw = 12";
DLC frames are 14 -> 48bytes
I read a controller :
I add a pause :
And I read next controller, with the same process, until the 12 controllers are read.
When finished, i do exactly same process
for the 12 write frames, with same pauses
It seems for me to be lot of usecs, no ?
Here, and when i lower pauses, i can see sometimes, bad/wrong values
(Like all 12 read values are written into a vector, i can see some values jump in another vector index !)
the controllers take nearly 150usec each to send frame, after a query.
Question1 : do you have better read/write loop process ? Any tuto to send the 3 ids frames from one port, in one time ? (anything like a multiplex ?)
Question2 : With the infos i gave you, when i send 3 different frames to the Peak 4canM2 same port, i must do a pause between each, correct ? what usec value should i use ?
Thanks Mr
Vincent
Well, I'm trying to have frames transmissions as solid as possible.
- Using PCAN-M.2 board with 4 ports, on up xtreme i7.
- ubuntu 20.04 RT
- TPCANBitrateFD BitrateFD = (char*) "f_clock_mhz = 80, nom_brp = 1, nom_tseg1 = 50, nom_tseg2 = 29, nom_sjw = 10, data_brp = 1, data_tseg1 = 8, data_tseg2 = 7, data_sjw = 12";
DLC frames are 14 -> 48bytes
I read a controller :
Code: Select all
moteus_rx_msg.ID = 0x8000 | id;
Status = CAN_ReadFD(port,&moteus_rx_msg, NULL);
usleep(100);
CAN_GetErrorText(Status, 0, strMsg);
if(Status != PCAN_ERROR_QRCVEMPTY){
memcpy(&_position, &moteus_rx_msg.DATA[MSGRX_ADDR_POSITION], sizeof(float));
...}
Code: Select all
usleep(150);
When finished, i do exactly same process
Code: Select all
Status = CAN_WriteFD(port, &moteus_tx_msg);
usleep(100); // peak delay on queue frame , no relation with Moteus boards.
CAN_GetErrorText(Status, 0, strMsg);
if(Status == PCAN_ERROR_OK){return(true);}
It seems for me to be lot of usecs, no ?
Here, and when i lower pauses, i can see sometimes, bad/wrong values
(Like all 12 read values are written into a vector, i can see some values jump in another vector index !)
the controllers take nearly 150usec each to send frame, after a query.
Question1 : do you have better read/write loop process ? Any tuto to send the 3 ids frames from one port, in one time ? (anything like a multiplex ?)
Question2 : With the infos i gave you, when i send 3 different frames to the Peak 4canM2 same port, i must do a pause between each, correct ? what usec value should i use ?
Thanks Mr
Vincent
- S.Grosjean
- Software Development
- Posts: 357
- Joined: Wed 4. Jul 2012, 17:02
Re: read or send multiple frame same time (peak 4canM2) c++
Hi,
Using libpcanbasic, you won't be able to write more than one frame at a time over a channel. Therefore, if you want to achieve some kind of parallelization, you will have to set up a multi-task architecture in your application (libpcanbasic is thread-safe).
Regards,
Using libpcanbasic, you won't be able to write more than one frame at a time over a channel. Therefore, if you want to achieve some kind of parallelization, you will have to set up a multi-task architecture in your application (libpcanbasic is thread-safe).
Regards,
— Stéphane