Open gmcbrien opened 5 years ago
It looks like your pi is running a DHCP server. You need to stop the DHCP server before running the script.
I killed DHCP - no luck I'm afraid :( The IP is actually assigned to my WLAN0 interface.
root@raspberrypi:/home/pi/TuyOTA# ps -ef | grep dhcp
root 497 1 0 21:00 ? 00:00:00 /sbin/dhcpcd -q -b
root 1954 1823 0 21:05 pts/0 00:00:00 grep dhcp
root@raspberrypi:/home/pi/TuyOTA# kill 497
root@raspberrypi:/home/pi/TuyOTA# ./tuyota.pl
Getting interface into stable state
RTNETLINK answers: Cannot assign requested address
Done
Using WiFi device wlan0 for Access Point
Starting Access Point with SSID ZAGDU-789
Giving Access Point IP address 10.44.57.1, pid is 1970
Unable to create DHCP Listener socket! Address already in use at ./tuyota.pl line 188.
Exiting....
Shutting down...
root@raspberrypi:/home/pi/TuyOTA# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether b8:27:eb:xx:xx:xx brd ff:ff:ff:ff:ff:ff
inet 192.168.1.41/24 brd 192.168.1.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::8dd6:f30a:xxxx:xxxx/64 scope link
valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether b8:27:eb:XX:XX:XX brd ff:ff:ff:ff:ff:ff
inet 192.168.1.143/24 brd 192.168.1.255 scope global wlan0
valid_lft forever preferred_lft forever
inet 10.44.57.1/24 scope global wlan0
valid_lft forever preferred_lft forever
root@raspberrypi:/home/pi/TuyOTA#
dhcpcd is the client daemon not the server. You have something listening on port 67.
Try the following:
# lsof -nP | grep UDP.*:67
It should show you what process is listening to that port.
It also looks like your wlan0 has an IP address which means there is something managing it. The script is unlikely to work if there are other processes managing the WiFi device.
It looks like I've got the same issue, though I can't see anything else controlling wlan0.
Starting Access Point with SSID ZAGDU-789
Giving Access Point IP address 10.44.57.1, pid is 747
Unable to create DHCP Listener socket! Address already in use at ./tuyota.pl line 188.
Exiting....
Shutting down...
**pi@raspberrypi:~/TuyOTA $ lsof -nP | grep UDP.*:67**
pi@raspberrypi:~/TuyOTA $ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
link/ether b8:27:eb:77:28:48 brd ff:ff:ff:ff:ff:ff
3: wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether 00:b0:8c:05:16:e1 brd ff:ff:ff:ff:ff:ff
inet 10.44.57.1/24 scope global wlan0
valid_lft forever preferred_lft forever
pi@raspberrypi:~/TuyOTA $
Did anyone manage to work out what's going on?
Have you tried running:
# lsof -nP | grep UDP.*:67
Yes, there was nothing output from the command, it's in the code pasted above
The lsof command should be run as root (sudo).
The error "Address already in use" usually means there is something else bound to the port and lsof should find the process.
Alternatively you could try:
sudo netstat -anlp
and look for an output line like this:
udp 0 0 0.0.0.0:67 ....
You could also try editing tuyota.pl and uncomment line 190 so it looks like this:
LocalAddr => $WiFiIPAddr,
I never got to the bottom of the issue, but I did manage to get the devices flashed using the Tuya-convert script. When I get a bit more time, I'll try to have another look at why I couldn't get this script working.
Thanks for all your help
Ok, I ran the lsof command as root and it looks like dnsmasq is on port 67. So that at least indicates why the script was failing
Device is a Teckin SP22. I ran the script via SSH. Session hung, so I ran it again locally and receive the following error.
The 192.168.1.12 address is the address of the plug, and can be pinged.
pi@raspberrypi:~/TuyOTA $ sudo ./tuyota.pl -ip 192.168.1.12 -s my_ssid -p my_ssid_password Getting interface into stable state RTNETLINK answers: Cannot assign requested address Done Using WiFi device wlan0 for Access Point Starting Access Point with SSID ZAGDU-789 Giving Access Point IP address 10.44.57.1, pid is 1395 Unable to create DHCP Listener socket! Address already in use at ./tuyota.pl line 188. Exiting.... Shutting down...
Any advice how to get further?
Happy to provide any further details, thanks!