sudo apt install wine // and install VCDS, cable drivers already are in Linux core, interface will be found and cable indicator will be active only when connected to car, on PC - Port OK, interface not found.
Identify COM ports on Linux
sudo dmesg | grep tty
ls /dev/ttyS* // typically refers to hardware serial ports.
ls /dev/ttyUSB* // refers to USB-to-serial converters.
ls /dev/ttyACM* // refers to USB CDC (Communications Device Class) devices.
lsusb
udevadm info -e | grep -E 'DEVNAME|ID_SERIAL'
Create the Symbolic Link
cd ~/.wine/dosdevices
ln -s /dev/ttyUSB0 com1 // map /dev/ttyUSB0 to COM1
rm com1 // if it exists and not needed
ls -l ~/.wine/dosdevices // verify the symbolic link
Add user to dialout group
sudo usermod -aG dialout $USER // add your user to the dialout group
cat /etc/group
grep dialout /etc/group
groups user
Change permissions
ls -l /dev/ttyUSB0 // list permissions
crw-rw---- 1 root dialout 188, 0 May 28 12:06 /dev/ttyUSB0
sudo chmod a+rw /dev/ttyUSB0 // change permissions
sudo lsof /dev/ttyS0 // If no output is returned, no process is currently using it. Ignore error.
Create a Test Script
sudo apt-get install python3-serial
touch test_serial.py
import serial
port = '/dev/ttyS0'
baudrate = 9600
ser = serial.Serial(port, baudrate, timeout=1)
ser.write(b'Hello, serial port!\n')
response = ser.readline()
print(response.decode('utf-8'))
ser.close()
python3 test_serial.py // run script
No comments:
Post a Comment