arsi-apli / CanFdToSerial

Serial port emulation over CAN FD bus.
GNU Lesser General Public License v3.0
8 stars 0 forks source link

Name the virtual serial ports according to the MCU CAN UUID #1

Open bondus opened 4 years ago

bondus commented 4 years ago

Assuming there is automatic discovery of the boards and they have an unique UUID it would be a good idea to name the virtual serial ports according to the UUIDs, much like klipper serial/linux USB system does.

Something like /tmp/ttyCAN0_ for a board connected to can bus0

This is a suggestion/discussion point, not really an issue.

arsi-apli commented 4 years ago

The problem is that ATSAM21C has no unique identifier. In other words, I did not find anything useful in the documentation.. My plan for CAN FD is to declare a new command:

DECL_COMMAND(command_config_can_address, "config_can_address address=%c");

and store it in the EEPROM/FLASH in the processor.

But in the CAN 2.0B implementation, do it according to your needs. Feel free to use the original CanSerial project and use only the new methods from generic / can_fd_support.c, saving 5 bytes for each message.

One more note on threads and the original CanSerial. Reading from the CAN socket is set to block with timeout set. What in one thread with TX can cause problems ..

/* set timeout */
    struct timeval tv;
    tv.tv_sec = 1;
    tv.tv_usec = 0;
    setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (const char*)&tv, sizeof tv);