Linux (CharDev) PCANBasic: Same ID received on all Channels

This forum covers PCAN-Linux and Linux development issues concerning our products
Post Reply
elpimous12
Posts: 59
Joined: Tue 3. Aug 2021, 23:34

Linux (CharDev) PCANBasic: Same ID received on all Channels

Post by elpimous12 » Fri 29. Mar 2024, 20:09

Hello the team, please a small help
- Working on ubuntu 20.04 RT,
- Peak CANFD M2 4 ports
- I have 12 ID's, 3 by CANFD port.

Need to query each ID, be certan to receive anything, and free queue after each end port query.

Code: Select all

bool read_moteus_RX_queue(int id, int port, float& position) {
        moteus_rx_msg.ID = 0x8000 | id;

        do
	    {
		    Status = CAN_ReadFD(port, &moteus_rx_msg, NULL);
            ros::Duration(0.000200).sleep();
	    } 
        while(!(Status ==PCAN_ERROR_QRCVEMPTY) && Status == PCAN_ERROR_OK);

        memcpy(&_position, &moteus_rx_msg.DATA[MSGRX_ADDR_POSITION], sizeof(float));
        position = _position;
        return true;
}
The position return is the same for all ID's on one port ?!

What did I miss ?

elpimous12
Posts: 59
Joined: Tue 3. Aug 2021, 23:34

Re: Linux (CharDev) PCANBasic: Same ID received on all Channels

Post by elpimous12 » Fri 29. Mar 2024, 20:13

I call read_moteus_RX_queue() like this :

Code: Select all

for (unsigned int jj=0; jj<3; ++jj)
    {
      // Reset values
      float RX_pos = 0.0;

      int port  = command.motor_adapters_[jj].getPort(); // PCAN_DEV1

      command.read_moteus_RX_queue(jj, port, RX_pos);  // query values;
      usleep(10);
    }
RX_pos for ID 1, 2, 3 return same value !!!!

M.Heidemann
Sales & Support
Sales & Support
Posts: 1083
Joined: Fri 20. Sep 2019, 13:31

Re: Linux (CharDev) PCANBasic: Same ID received on all Channels

Post by M.Heidemann » Wed 3. Apr 2024, 09:12

Hello,

Some recommendations regarding this:

1)
If you only read upon getting 'PCAN_ERROR_OK' returned, you might be unable to catch any issues regarding your physical bus.
Also not all TPCANStatus returns which are not 'PCAN_ERROR_OK' necessarily stop communication on the bus.

2)
You could print the received messages to console, make sure no alteration to the message on your part are done to them.
If the values remain the same, they are indeed the same on the bus for those 3 IDs.
That could be down to the hardware you are working with, maybe there is a valid reason for this (We are not familiar with Moteus)

Give this a try and tell me if this has yielded any results.

Best Regards

Marvin
---
Marvin Heidemann
PEAK-Support Team

Post Reply