nebulous / infinitude

Open control of Carrier/Bryant thermostats
MIT License
225 stars 50 forks source link

USB Web Socket #100

Closed andyopengit closed 4 years ago

andyopengit commented 4 years ago

Apologies if this is not the correct place for this.

I'm running infinitude on a Pi and have connected it to the RS485 ABCD connector on my intinify system. When I run infinitIVE, I clearly see information coming from the serial port. However when I run infinitUDE, I'm unable to determine if it is able to see data. I'm not very familiar with web sockets for serial modules. I see no output on the serial tab of the infinitude web interface. Netstat does not show anything listening on port 23 when infinitude is running either.

Any insights/help would be greatly appreciated!

nebulous commented 4 years ago

Does infinitude detect your serial adaptor? If Infinitude is able to detect and open your serial port then you should get some data in the serial tab on the frontend.

If infinitude isn't detecting your serial port, then set SERIAL_TTY if it is detecting the correct serial port, try resetting with the following:

replacing /dev/ttyAMA0 with your serial device stty < /dev/ttyAMA0 38400 -echo -opost -isig -icanon min 1

andyopengit commented 4 years ago

Many many thanks for the reply!

The Pi is detecting the serial device as /dev/ttyUSB0, and I've also tried resetting as you suggested. The parameter is set in the JSON file as below, I've also tried to escape the "/" in the device location.

{
    "app_secret": "Pogotudinal",
    "pass_reqs": 1020,
    "serial_socket": "127.0.0.1:23",
    "serial_tty": "/dev/ttyUSB0"
}

My thought was that maybe the serial port is receiving the data but that it was not being made available to the web socket for display.

The only way I know to test that the RS485 adapter is receiving data is to load up infinitIVE which again I am able to do using that device address and see data.

Should I see the computer listening on port 23? If so I'm not seeing that.

Active Internet connections (only servers)\
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN     
tcp6       0      0 :::22                   :::*                    LISTEN     
tcp6       0      0 ::1:6010                :::*                    LISTEN     
udp        0      0 0.0.0.0:50889           0.0.0.0:*                          
udp        0      0 0.0.0.0:5353            0.0.0.0:*                          
udp        0      0 0.0.0.0:68              0.0.0.0:*                          
udp6       0      0 :::5353                 :::*                               
udp6       0      0 :::43421                :::*                               
raw6       0      0 :::58                   :::*                    7          
Active UNIX domain sockets (only servers)
Proto RefCnt Flags       Type       State         I-Node   Path
unix  2      [ ACC ]     STREAM     LISTENING     8447     /run/systemd/journal/stdout
unix  2      [ ACC ]     STREAM     LISTENING     485232   /tmp/ssh-Vg2X6byuup/agent.27687
unix  2      [ ACC ]     STREAM     LISTENING     13681    /var/run/dhcpcd.sock
unix  2      [ ACC ]     STREAM     LISTENING     13683    /var/run/dhcpcd.unpriv.sock
unix  2      [ ACC ]     STREAM     LISTENING     6527     /run/systemd/fsck.progress
unix  2      [ ACC ]     STREAM     LISTENING     12418    /run/avahi-daemon/socket
unix  2      [ ACC ]     STREAM     LISTENING     12423    /var/run/dbus/system_bus_socket
unix  2      [ ACC ]     STREAM     LISTENING     12427    /run/thd.socket
unix  2      [ ACC ]     STREAM     LISTENING     478140   /run/user/1000/systemd/private
unix  2      [ ACC ]     STREAM     LISTENING     478146   /run/user/1000/gnupg/S.gpg-agent
unix  2      [ ACC ]     STREAM     LISTENING     478149   /run/user/1000/gnupg/S.gpg-agent.ssh
unix  2      [ ACC ]     STREAM     LISTENING     478151   /run/user/1000/gnupg/S.gpg-agent.browser
unix  2      [ ACC ]     STREAM     LISTENING     478153   /run/user/1000/gnupg/S.gpg-agent.extra
unix  2      [ ACC ]     STREAM     LISTENING     478155   /run/user/1000/gnupg/S.dirmngr
unix  2      [ ACC ]     STREAM     LISTENING     8436     /run/systemd/private
unix  2      [ ACC ]     SEQPACKET  LISTENING     8442     /run/udev/control
nebulous commented 4 years ago

serial_tty and serial_socket are mutually exclusive. If you're using a usb serial adaptor, just use serial_tty, and if you're using a separate networked serial device like an esp8266 or a serial bridge, then use serial_socket.

since you're using a usb serial adaptor, then you should use serial_tty and remove serial_socket since it's a distraction. There will be nothing listening on port 23. When you open the serial tab in Infinitude, it opens a websocket between your browser and Infinitude, Infinitude opens the serial port and reads from it directly(make sure that the user infinitude runs as has rw access to the serial device) and pipes any data frames it finds through the websocket.

Here's a diagram of both options which might be easier to grok than my rambling image

What does infinitude output in the logs when you open the serial port? Are you using a docker image, or running directly? If you have a C compiler you can use cardump in the dist folder to test and/or reset the device to a known state. Though Infinitive seems to have proven that at least works already.

edit: Also, which thermostat are you using?

nebulous commented 4 years ago

@andyopengit ping. I'll close this as stale soon.

andyopengit commented 4 years ago

@nebulous my apologies as I've been buried in work and no away on vacation. That makes perfect sense now that you've explained it. I mistakenly assumed that the web interface was getting that information that way. I will compile cardump but as you suggest since it's working with infinitive probably won't provide much.

I am running directly on a Raspberry Pi 3+. More likely it's an issue with permissions. I will check that next week when I return to the house.

Equipment I'm using is: Wall Unit: SYSTXCCITC01-B Software Version: 131626-03.40

scyto commented 4 years ago

@andyopengit i can confirm, setting both serial variables (even if one is null, i had set the serial_tty to null on my container) does break serial over TCP/IP - i had to make sure only one var was defined to get serial over TCP/IP FWIW.

andyopengit commented 4 years ago

I appreciate everyone's help! I'll be away for a few weeks so won't be able to check until I return home. Feel free to close this and I'll ask you to reopen if I can't get it working.