{"id":5123,"date":"2023-09-15T14:53:57","date_gmt":"2023-09-15T06:53:57","guid":{"rendered":"https:\/\/www.tosunai.com\/?p=5123"},"modified":"2024-09-02T12:26:11","modified_gmt":"2024-09-02T04:26:11","slug":"tosun-hardware-use-socketcan-to-send-and-receive-messages","status":"publish","type":"post","link":"https:\/\/www.tosunai.com\/en\/tosun-hardware-use-socketcan-to-send-and-receive-messages\/","title":{"rendered":"How to use SocketCAN to send\/receive telegrams with TOSUN Hardware"},"content":{"rendered":"
1.1 Socket CAN<\/b><\/p>
SocketCAN is a CAN protocol stack maintained by the Linux kernel, and you can use the Socket API provided by the Linux kernel to read and write operations on the CAN bus. Users only need to use the C language to realize the communication with the Socket API, and then they can control the nodes on the CAN bus to realize the sending and receiving of data.<\/span><\/span><\/p> If you want to use SocketCAN to control TSCAN devices, one solution is to use the virtual SocketCAN that comes with Linux. we use libTSCANApiOnLinux.so, a Linux library provided by TOSUN, to complete a vcan server program on the local machine for interchanging the messages from SocketCAN and libTSCAN.<\/span><\/p> Configuring the baud rate of the TOSUN hardware this way, as well as viewing the information needs to be in the sockettscan program. Because vcan itself doesn't support baud rate configuration, we can't tell vcan about the statistics.<\/span><\/p> The logic diagram is shown below:<\/span><\/span><\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t 2.1 System environment configuration<\/b><\/p> This step can be ignored if the computer's own system is Linux.<\/span><\/span><\/p> 1) Via http:\/\/releases.ubuntu.com\/18.04\/\u53ef\u4ee5\u4e0b\u8f7dUbuntu\u7cfb\u7edf\u955c\u50cf.<\/span><\/span><\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t 2) Import mapping file in VM: VM -> Edit VM Settings -> CD\/DVD -> Use ISO mapping file.<\/span><\/font>Second, the use of Socket CAN tutorial<\/h4>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
Socket CAN Using Toturials<\/h5>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t
<\/p>\n
<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t