DeskPi-Team / deskpi

DeskPi Pro is the Ultimate Case Kit for Raspberry Pi 4 with Full Size HDMI/2.5 Hard Disk Support and Safe Power Button, It has QC 3.0 Power Supply inside and New ICE Tower Cooler inside.
GNU General Public License v3.0
143 stars 46 forks source link

pwmFanControl64 is opening serial port /dev/ttyUSB0 #153

Closed mgrouch closed 2 months ago

mgrouch commented 1 year ago

ttyUSB0 is FTDI USB to serial adapter which has nothing to do with deskpi pro! Absolutely unrelated device.


lrwxrwxrwx  1 root root          7 Jul 21 01:33 /dev/ttyLYS_ftdi_AO009078 -> ttyUSB0

user@lysmarine:~ $ sudo lsof /dev/ttyUSB0
lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs
      Output information may be incomplete.
lsof: WARNING: can't stat() fuse.portal file system /run/user/1000/doc
      Output information may be incomplete.
COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
pwmFanCon 1509 root    3u   CHR  188,0      0t0  442 /dev/ttyUSB0
f-io commented 1 year ago

had the same problem, in my case ttyUSB0 is an USB-> serial -> EnOcean device. Please update your driver to check first and not just hardcode the port.

paulwratt commented 11 months ago

deskpi-config has this at line 14 (just like it is hard coded in line 16 of pwmControlFan.c):

serial_port='/dev/ttyUSB0'

I dont have any other USB TTY devices, so someone else will have to do some testing and /sys/class/ lookups to see where the DeskPi TTY device ends up when you have another USB TTY device plugged in

HINT: on RPi the USB devices are assigned from top-down, left -to-right , which corresponds to there USB ID numbers (lowest to highest). /dev/ttyUSB0 only gets assigned to the DeskPi if no other USB TTY devices have already been registered with the stack.

NOTE: this does not take into account the front USB ports either, which is why some testing is needed. Also it might be possible to get (instead of put only) a value to the DeskPi USB TTY device, and get a known response back (eg like requesting the current PWM % maybe?), in which case you could blindly poll all the USB TTY devices , as long as you know what you are looking for per device.

f-io commented 10 months ago

@yoyojacky possible solution, use udev rules.

In this case within your install script:

#!/bin/bash

# create a udev rule for serial communication
UDEVRULE="ACTION==\"add\", ATTRS{idVendor}==\"1d6b\", ATTRS{idProduct}==\"0002\", SYMLINK+=\"deskPiPro\""
if [ ! -f /etc/udev/rules.d/10-local.rules ]; then
  echo -e $UDEVRULE >> /etc/udev/rules.d/10-local.rules
else
  checkResult=`grep "$UDEVRULE" /etc/udev/rules.d/10-local.rules`
  if [ $? -ne 0 ];  then
    echo -e $UDEVRULE >> /etc/udev/rules.d/10-local.rules
  fi
fi

The system will atomically create a symlink /dev/deskPiPro as soon as it finds a USB device with matching idVendor && idProduct. Now you can talk to the device by serialport serial_port='/dev/deskPiPro'

yoyojacky commented 7 months ago

yes, udev rule is better, I will try it on my test device, and update the script.

yoyojacky commented 4 months ago

@f-io I've tried this, but and adding a udev rule file to /etc/udev/rules.d/10-deskpi.rules and it can generate a symbolic link to /dev/ttyUSB0, like aliase name, but once I am trying to operate this device : /dev/deskPiPro it will not work properly. for example : echo "pwm_100" > /dev/deskPiPro
it will not trigger the fan spinning, but if i send the same command to /dev/ttyUSB0, it works fine . and i have change the owner of the /dev/deskPiPro to current user by using chown command and chmod command .

yoyojacky commented 2 months ago

had the same problem, in my case ttyUSB0 is an USB-> serial -> EnOcean device. Please update your driver to check first and not just hardcode the port.

Did you connect other USB device on your raspberry pi or just deskpi pro?