Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrupt response from panel: Unexpected start, expected 't', got 0x9 #77

Closed
leocrawford opened this issue Jan 2, 2023 · 13 comments
Closed
Assignees

Comments

@leocrawford
Copy link

leocrawford commented Jan 2, 2023

Describe the bug
When starting it reports Corrupt response from panel: Unexpected start, expected 't', got 0x9.

This appears to be before auth, so we have:

HA: 04 5a a2
alarm: 0b 5a 05 01 00 00 01 05
alarm: 09 00 85

If I compare this to a dump from wintex, the sequence is the same and the auth happens in the following step.

The alarm is connected via a raspberry pi zero W hanging off the on-board serial port, using ser2net. The alarm settings are.

image

Wintex works fine.

Application version
1.2.3

Texecom alarm type
Premier Elite 48, firmware V6.02.00LS1

Home Assistant version
2022.10.1

Debug log
2023-01-02 14:25:05 - INFO: Starting texecom2mqtt v1.2.3 (Node v16.13.0)...
2023-01-02 14:25:05 - INFO: Connected to alarm, sleeping for 2 seconds...
2023-01-02 14:25:07 - INFO: Connection ready
2023-01-02 14:25:07 - INFO: Logging in to panel
2023-01-02 14:25:07 - ERROR: Corrupt response from panel: Unexpected start, expected 't', got 0x9
2023-01-02 14:25:07 - INFO: Panel disconnected

@leocrawford
Copy link
Author

leocrawford commented Jan 8, 2023

Trying to debug further, using pialarm (https://github.com/shuckc/pialarm) as a fake texecom unit (emulating a premier elite 24)

The connect sequence starts the same, but after the alarm responds for the first time the HA starts sending:

74 43 0a 00 01 31 32 33 34 34

In total it sends it five times, before aborting. Looking at the protocol defined here (https://github.com/shuckc/pialarm/blob/master/protocol/wintex-protocol.md) This seems odd, as the first byte should be be length of the message in bytes (10 in this case). The corresponding send from wintex (which seems to meet the standard I'd expect is)

07 5a 31 32 33 34 d4

This suggests a slightly different protocol, with 64 added (the most significant bit), a different command code and then three extra bytes .

I'm happy to get the NDA signed to try and get the code and debug from there, but struggling to find anything on-line. If anyone has a link I'd appreciate it.

@leocrawford
Copy link
Author

leocrawford commented Jan 14, 2023

OK. Found a fix.

The packet captures above showed that the response from the alarm was being spit over two packets, despite being only 11 bytes long. The first byte of the second packet was 09 as reported in the error. I wondered if it was the timing and/or packet alignment causing this so I started fiddling with ser2net and find the following ser2net.yaml connection works.

    accepter: tcp,10001
    enable: on
    options:
      kickolduser: true
      chardelay: true
      max-connections: 1 
      chardelay-scale: 240
      chardelay-min: 5000
      chardelay-max: 100000
    connector: serialdev,
              /dev/ttyAMA0,
              19200n82
              local   

Ideally the code would be less sensitive to packet timing/splits, but at least we have a workaround

@metaljay
Copy link

@leocrawford do you still have this error using esphome?
I am getting a similar error but using ESP-Link

#97

@leocrawford
Copy link
Author

No. I haven't experienced that on ESPLink (or at least not that I have noticed).

@metaljay
Copy link

Can you help debug with me? (Not sure who else to ask)

@leocrawford
Copy link
Author

sure. What is the serial config on your esphome?

@metaljay
Copy link

metaljay commented Sep 21, 2024

I didn’t have any joy with ESPHome, I used ESPlink instead.

IMG_0005
IMG_5624
IMG_0007

@leocrawford
Copy link
Author

leocrawford commented Sep 22, 2024

given that EspLink doesn't seem to have the equivalent of chardelay, I think the easiest thing would be to try lowering the baud rate to something very slow. You'll have to change both ends; the alarm one via wintex and this end via esplink.

@metaljay
Copy link

metaljay commented Sep 26, 2024

I have totally lost the plot with this now. Board remains the same as above (as in using pin 0 and 1)
I refreshed with ESP home like you did, my config looks good

esphome:
  name: texecom-link
  friendly_name: texecom-link

esp8266:
  board: d1

external_components:
  - source: github://oxan/esphome-stream-server

stream_server:
  uart_id: uart_bus
  port: 23

binary_sensor:
  - platform: stream_server
    connected:
      name: texecom-link

uart:
  id: uart_bus
  tx_pin: GPIO1
  rx_pin: GPIO3
  baud_rate: 19200  
  data_bits: 8      
  stop_bits: 2      

web_server:
  port: 80

# Enable logging
logger:
  level: DEBUG

# Enable Home Assistant API
api:

ota:
  platform: esphome

wifi:
  ssid: "XXX"
  password: "XXX"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Texecom-Link Fallback Hotspot"
    password: "123456789"

captive_portal:

I can see from the debug terminal on ESPHome that it tries to connect to the Texecom but it never actually gets through.
So frustrating

@leocrawford
Copy link
Author

leocrawford commented Sep 26, 2024 via email

@metaljay
Copy link

metaljay commented Sep 26, 2024

According to the D1 pinout (same board you have) the bottom two pins (TX and RX) are labelled as GPIO1 and GPIO3

im not smart enough to understand what you mean on points 2 and 3 (ill ask chatGPT to help dumb it down for me haha).

I can't adjust the baud rate on comport 3 so I imagine it's 19200 on the Texecom side too?

My esphome log looks like this, when 192.168.2.254 connects that's my texecom2MQTT add-on trying to connect but it errors out (so .254 is the add-on, .182 is the ESP8266):

[15:19:46][C][wifi:600]: WiFi:
[15:19:46][C][wifi:428]:   Local MAC: 30:83:98:A7:62:FB
[15:19:46][C][wifi:433]:   SSID: 'The White House - IoT'
[15:19:46][C][wifi:436]:   IP Address: 192.168.2.182
[15:19:46][C][wifi:439]:   BSSID: 9C:05:D6:A3:28:90
[15:19:46][C][wifi:441]:   Hostname: 'texecom-link'
[15:19:46][C][wifi:443]:   Signal strength: -77 dB ▂▄▆█
[15:19:46][C][wifi:447]:   Channel: 6
[15:19:46][C][wifi:448]:   Subnet: 255.255.255.0
[15:19:46][C][wifi:449]:   Gateway: 192.168.2.1
[15:19:46][C][wifi:450]:   DNS1: 192.168.2.254
[15:19:46][C][wifi:451]:   DNS2: 192.168.1.1
[15:19:46][C][logger:185]: Logger:
[15:19:46][C][logger:186]:   Level: DEBUG
[15:19:46][C][logger:188]:   Log Baud Rate: 0
[15:19:46][C][logger:189]:   Hardware UART: UART0
[15:19:46][C][uart.arduino_esp8266:118]: UART Bus:
[15:19:46][C][uart.arduino_esp8266:119]:   TX Pin: GPIO1
[15:19:46][C][uart.arduino_esp8266:120]:   RX Pin: GPIO3
[15:19:46][C][uart.arduino_esp8266:122]:   RX Buffer Size: 256
[15:19:46][C][uart.arduino_esp8266:124]:   Baud Rate: 19200 baud
[15:19:46][C][uart.arduino_esp8266:125]:   Data Bits: 8
[15:19:46][C][uart.arduino_esp8266:126]:   Parity: NONE
[15:19:46][C][uart.arduino_esp8266:127]:   Stop bits: 2
[15:19:46][C][uart.arduino_esp8266:129]:   Using hardware serial interface.
[15:19:46][C][captive_portal:089]: Captive Portal:
[15:19:46][C][web_server:145]: Web Server:
[15:19:46][C][web_server:146]:   Address: texecom-link.local:80
[15:19:46][C][mdns:116]: mDNS:
[15:19:46][C][mdns:117]:   Hostname: texecom-link
[15:19:46][C][esphome.ota:073]: Over-The-Air updates:
[15:19:46][C][esphome.ota:074]:   Address: texecom-link.local:8266
[15:19:46][C][esphome.ota:075]:   Version: 2
[15:19:46][C][safe_mode:018]: Safe Mode:
[15:19:46][C][safe_mode:019]:   Boot considered successful after 60 seconds
[15:19:46][C][safe_mode:021]:   Invoke after 10 boot attempts
[15:19:46][C][safe_mode:022]:   Remain in safe mode for 300 seconds
[15:19:46][C][api:139]: API Server:
[15:19:46][C][api:140]:   Address: texecom-link.local:6053
[15:19:46][C][api:144]:   Using noise encryption: NO
[15:19:46][C][stream_server:045]: Stream Server:
[15:19:46][C][stream_server:046]:   Address: texecom-link.local:23
[15:19:46][C][stream_server:048]:   Connected: 'texecom-link'
[15:19:46][C][stream_server:048]:     Device Class: 'connectivity'
[15:20:36][I][safe_mode:041]: Boot seems successful; resetting boot loop counter
[15:22:00][D][stream_server:081]: New client connected from 192.168.2.254
[15:22:00][D][binary_sensor:036]: 'texecom-link': Sending state ON
[15:22:19][D][stream_server:163]: Client 192.168.2.254 disconnected
[15:22:19][D][binary_sensor:036]: 'texecom-link': Sending state OFF
[15:22:40][D][stream_server:081]: New client connected from 192.168.2.254
[15:22:40][D][binary_sensor:036]: 'texecom-link': Sending state ON
2024-09-26 14:24:34 - INFO: Starting texecom2mqtt v1.2.3 (Node v16.13.0)...
2024-09-26 14:24:34 - INFO: Connected to alarm, sleeping for 2 seconds...
2024-09-26 14:24:36 - DEBUG: Fetched data from cache
2024-09-26 14:24:36 - INFO: Connection ready
2024-09-26 14:24:36 - INFO: Logging in to panel
2024-09-26 14:24:39 - DEBUG: Command 1 timed out (attempt 1, id: 0).
2024-09-26 14:24:43 - DEBUG: Command 1 timed out (attempt 2, id: 0).
2024-09-26 14:24:46 - DEBUG: Command 1 timed out (attempt 3, id: 0).
2024-09-26 14:24:50 - DEBUG: Command 1 timed out (attempt 4, id: 0).
2024-09-26 14:24:53 - DEBUG: Command 1 timed out (attempt 5, id: 0).
2024-09-26 14:24:53 - ERROR: Unhandled rejection - Command 1 timed out 5 times and could not be completed
2024-09-26 14:24:53 - DEBUG: Closing connection to panel
Screenshot 2024-09-26 at 3 28 35 pm

If I try 'sudo tcpdump -i en0 tcp and host 192.168.2.182 (the ESP) and host 192.168.2.254 (home assistant)' it doesn't look like any data is being sent - which doesn't make sense as I can see in ESPhome log that it tries to connect..

HA has it connecting and disconnecting all the time too
Screenshot 2024-09-26 at 4 02 44 pm

@leocrawford
Copy link
Author

Ok, working backwards...

The Logbook entries show a successful connection between your serial client (the texecom mqtt plugin) and the server, so if it is failing to connect then it is no surprise that it disconnects/reconnects again and again.

If you drop to the command line and try nc texecom-link.local:23 you should a) be able to send and receive bytes (I'd expect you to get garbage back) and b) see your connection appear the the Logbook section. incidentally your second repetition of 'texecom-link' is odd, as I'd have thought your original config that it should be called 'uart_bus', but maybe you changed it?

On that note:

  • I defined the stream server after the uart section (not sure if it matters)
  • I named my board esp12e, rather than d1 (again not sure if it matters)
  • I set logger: baud_rate: 0. This might be required to stop the board logs being sent over UART, and interfering with the texecom

Other thoughts:

  1. You are swapping tx/rx from the alarm to the board aren't you? So rx goes to tx and vice versa?
  2. Are you plugged into com2 or 3? you suggest 3, but if so you need to change it to ComIP away from crestron.

Instead of trying to connect from texecom2mqtt (actually disable it) try connecting from wintex instead, as you know that works. Once you have that working, graduate to texecom2mqtt.

Finally you said you got nothing from tcpdump. Which device were you running it on? It should work if you're on the esphome host. Anything else requires thought about whether the packets will pass through it. Generally they would with a router (actually acting as a switch), but if they were both wireless then you wouldn't see them as you're listening on ethernet.. and you might not see them anyway if the wireless switches directly without dropping down to the CPU.

@leocrawford
Copy link
Author

leocrawford commented Sep 26, 2024

My wintex config, so actually listed as "nothing fitted"

image

and the config to then reach said device over wintex

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants