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

Using Tasmota "script serial" in 8E1 mode calculates the parity bit wrong #19497

Closed
1 of 5 tasks
Dobie007 opened this issue Sep 11, 2023 · 4 comments · Fixed by #19505
Closed
1 of 5 tasks

Using Tasmota "script serial" in 8E1 mode calculates the parity bit wrong #19497

Dobie007 opened this issue Sep 11, 2023 · 4 comments · Fixed by #19505

Comments

@Dobie007
Copy link

Dobie007 commented Sep 11, 2023

PROBLEM DESCRIPTION

A clear and concise description of what the problem is.
With the Tasmota scripting function the parity check seems faulty: If it is set to 8E1 the result is not as expected. 8O1 seems to have the same issue.

REQUESTED INFORMATION

Make sure your have performed every step and checked the applicable boxes before submitting your issue. Thank you!

  • [x ] Read the Contributing Guide and Policy and the Code of Conduct
  • Searched the problem in issues
  • [X ] Searched the problem in discussions
  • [X ] Searched the problem in the docs
  • Searched the problem in the chat
  • [X ] Device used (e.g., Sonoff Basic): TYWE1S
  • [X ] Tasmota binary firmware version number used: 13.1.0
    • Pre-compiled
    • [X ] Self-compiled
  • [X ] Flashing tools used:Tasmotizer and OTA
  • [X ] Provide the output of command: Backlog Template; Module; GPIO 255:
  Configuration output here:
17:28:48.455 CMD: Grp 0, Cmd 'BACKLOG', Idx 1, Len 0, Pld -99, Data ''
17:28:48.478 MQT: stat/tasmota_3B510A/RESULT = {"Backlog":"Empty"}

17:30:20.063 CMD: Template
17:30:20.065 SRC: WebConsole from 192.168.0.61
17:30:20.069 CMD: Grp 0, Cmd 'TEMPLATE', Idx 1, Len 0, Pld -99, Data ''
17:30:20.094 MQT: stat/tasmota_3B510A/RESULT = {"NAME":"Generic","GPIO":[1,1,1,1,1,1,1,1,1,1,1,1,1,1],"FLAG":0,"BASE":18}

17:31:30.620 CMD: Grp 0, Cmd 'MODULE', Idx 1, Len 0, Pld -99, Data ''
17:31:30.641 MQT: stat/tasmota_3B510A/RESULT = {"Module":{"18":"Generic"}}

17:32:57.153 CMD: GPIO 255
17:32:57.155 SRC: WebConsole from 192.168.0.61
17:32:57.158 CMD: Grp 0, Cmd 'GPIO', Idx 1, Len 3, Pld 255, Data '255'
17:32:57.186 MQT: stat/tasmota_3B510A/RESULT = {"GPIO0":{"0":"None"},"GPIO1":{"0":"None"},"GPIO2":{"0":"None"},"GPIO3":{"0":"None"},"GPIO4":{"0":"None"},"GPIO5":{"0":"None"},"GPIO9":{"0":"None"},"GPIO10":{"0":"None"},"GPIO12":{"0":"None"},"GPIO13":{"0":"None"},"GPIO14":{"0":"None"},"GPIO15":{"0":"None"},"GPIO16":{"0":"None"},"GPIO17":{"0":"None"}}
  • [X ] If using rules, provide the output of this command: Backlog Rule1; Rule2; Rule3:
  Rules output here:
not used
  • Provide the output of this command: Status 0:
  STATUS 0 output here:
17:34:45.970 CMD: Status 0
17:34:45.973 SRC: WebConsole from 192.168.0.61
17:34:45.976 CMD: Grp 0, Cmd 'STATUS', Idx 1, Len 1, Pld 0, Data '0'
17:34:46.000 MQT: stat/tasmota_3B510A/STATUS = {"Status":{"Module":18,"DeviceName":"Tasmota","FriendlyName":["Tasmota"],"Topic":"tasmota_3B510A","ButtonTopic":"0","Power":0,"PowerOnState":3,"LedState":1,"LedMask":"FFFF","SaveData":1,"SaveState":1,"SwitchTopic":"0","SwitchMode":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"ButtonRetain":0,"SwitchRetain":0,"SensorRetain":0,"PowerRetain":0,"InfoRetain":0,"StateRetain":0,"StatusRetain":0}}
17:34:46.524 MQT: stat/tasmota_3B510A/STATUS1 = {"StatusPRM":{"Baudrate":9600,"SerialConfig":"8E1","GroupTopic":"tasmotas","OtaUrl":"http://ota.tasmota.com/tasmota/release/tasmota-lite.bin.gz","RestartReason":"Software/System restart","Uptime":"1T00:42:22","StartupUTC":"2023-09-10T15:52:24","Sleep":50,"CfgHolder":4617,"BootCount":72,"BCResetTime":"2023-09-02T18:11:41","SaveCount":407,"SaveAddress":"F7000"}}
17:34:46.991 MQT: stat/tasmota_3B510A/STATUS2 = {"StatusFWR":{"Version":"13.1.0(tasmota)","BuildDateTime":"2023-09-10T17:51:00","Boot":31,"Core":"2_7_4_9","SDK":"2.2.2-dev(38a443e)","CpuFrequency":80,"Hardware":"ESP8266EX","CR":"386/699"}}
17:34:47.002 MQT: stat/tasmota_3B510A/STATUS3 = {"StatusLOG":{"SerialLog":4,"WebLog":4,"MqttLog":1,"SysLog":4,"LogHost":"","LogPort":514,"SSId":["UPC2659815",""],"TelePeriod":300,"Resolution":"558180C0","SetOption":["00808009","2805C80001000600003C5A0A192800000000","00000080","00006000","00004000","00000000"]}}
17:34:47.367 MQT: stat/tasmota_3B510A/STATUS4 = {"StatusMEM":{"ProgramSize":526,"Free":476,"Heap":22,"ProgramFlashSize":1024,"FlashSize":2048,"FlashChipId":"1540C8","FlashFrequency":40,"FlashMode":"DOUT","Features":["00000809","07800782","04180001","00000003","00000000","00000000","00000000","00000000","04000000","00000000"],"Drivers":"1,2,4,8,9,10,12,20,21,62,68","Sensors":"1,2"}}
17:34:48.001 MQT: stat/tasmota_3B510A/STATUS5 = {"StatusNET":{"Hostname":"tasmota-3B510A-4362","IPAddress":"192.168.0.47","Gateway":"192.168.0.1","Subnetmask":"255.255.255.0","DNSServer1":"192.168.0.1","DNSServer2":"192.168.0.2","Mac":"98:CD:AC:3B:51:0A","Webserver":2,"HTTP_API":1,"WifiConfig":4,"WifiPower":17.0}}
17:34:48.363 MQT: stat/tasmota_3B510A/STATUS6 = {"StatusMQT":{"MqttHost":"192.168.0.140","MqttPort":1883,"MqttClientMask":"DVES_%06X","MqttClient":"DVES_3B510A","MqttUser":"XXXXX","MqttCount":1,"MAX_PACKET_SIZE":1200,"KEEPALIVE":30,"SOCKET_TIMEOUT":4}}
17:34:48.660 MQT: stat/tasmota_3B510A/STATUS7 = {"StatusTIM":{"UTC":"2023-09-11T16:34:48","Local":"2023-09-11T17:34:48","StartDST":"2023-03-26T02:00:00","EndDST":"2023-10-29T03:00:00","Timezone":"+01:00","Sunrise":"06:21","Sunset":"19:12"}}
17:34:49.002 MQT: stat/tasmota_3B510A/STATUS10 = {"StatusSNS":{"Time":"2023-09-11T17:34:48"}}
17:34:49.108 MQT: stat/tasmota_3B510A/STATUS11 = {"StatusSTS":{"Time":"2023-09-11T17:34:49","Uptime":"1T00:42:25","UptimeSec":88945,"Heap":22,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"Wifi":{"AP":1,"SSId":"XXXXXX","BSSId":"88:F7:C7:50:70:C7","Channel":11,"Mode":"11n","RSSI":68,"Signal":-66,"LinkCount":1,"Downtime":"0T00:00:06"}}}
  • Set weblog to 4 and then, when you experience your issue, provide the output of the Console log:
  Console output here:
17:37:42.589 send 
17:37:43.594 send 
17:37:44.595 send 
17:37:45.597 send 
17:37:46.597 send 
17:37:47.599 send 
17:37:48.603 send 
17:37:49.605 send 
17:37:50.607 send 
17:37:51.556 WIF: Checking connection...
17:37:51.611 send 
17:37:52.612 send 
17:37:53.615 send 
17:37:54.617 send 
17:37:55.619 send 

TO REPRODUCE

Steps to reproduce the behavior:
compile firmware with: user override options:

#ifndef USE_SCRIPT
#define USE_SCRIPT // adds about 17k flash size, variable ram size
#endif
#ifdef USE_RULES
#undef USE_RULES
#endif

#define USE_SCRIPT_SERIAL
#define USE_SCRIPT_JSON_EXPORT
#define USE_SCRIPT_WEB_DISPLAY

#ifdef USE_DOMOTICZ
#undef USE_DOMOTICZ
#endif

#ifdef USE_SML_M
#undef USE_SML_M
#endif

copy the script in to the script console

D 128
m:trx_a=0 8

B
so(13 15 9600 8E1)
; preset cmd BB 00 01 04 02 01 00 BD
trx_a[1]=0xBB
trx_a[2]=0x00
trx_a[3]=0x01
trx_a[4]=0x04
trx_a[5]=0x02
trx_a[6]=0x01
trx_a[7]=0x00
trx_a[8]=0xBD

S
; send next cmd array with no checksum
print send
swa(trx_a 8)

Connect a oscilloscope or a terminal receiver to the serial output at GPIO15 and set it to 9600 baud and 8E1
The bytes in the script should be received with a correct parity bit set - "Even"

The first sent byte 0xBB = 1011 1011 has 6 bits set so that the parity bit should not be set.
As visible in the screenshot of my Picoscope the bit is set (red marked bits are correct while the blue ones are wrong). Strangely enough it is not always wrong.
Besides that the connected ACSystem does not respond.

EXPECTED BEHAVIOUR

A clear and concise description of what you expected to happen.
The parity bit should be set if the number of set bits is uneven and not set when even:

SCREENSHOTS

If applicable, add screenshots to help explain your problem.
grafik

ADDITIONAL CONTEXT

Add any other context about the problem here.
Transmitting the same data with the Serialsend5 command gives a correct result (with an answer from the connected AC system):
17:54:09.990 CMD: SerialConfig 8E1
17:54:09.994 CMD: Grp 0, Cmd 'SERIALCONFIG', Idx 1, Len 3, Pld 8, Data '8E1'

17:56:23.640 CMD: SerialSend5 BB000104020100BD
17:56:23.646 CMD: Grp 0, Cmd 'SERIALSEND', Idx 5, Len 16, Pld -99, Data 'BB000104020100BD'
{"SerialReceived":"BB01000437040021950000000000000000730308000000000000000000006EFF40000031303C00008000000000DD0000004440000000001A00000000EE"}

grafik

Changing to 8N1 or setting 7N1 works as expected on the oscilloscope output...

see also: #19236 for further details on what we are doing...

(Please, remember to close the issue when the problem has been addressed)

@Dobie007 Dobie007 changed the title In Tasmotaserial script the parity bit is not calculated correctly Using Tasmota "script serial" in 8E1 mode calculates the parity bit wrong Sep 11, 2023
@s-hadinger
Copy link
Collaborator

This is specific to Scripter. Can you reproduce with standard Tasmota Serial commands?

@Dobie007
Copy link
Author

This is specific to Scripter. Can you reproduce with standard Tasmota Serial commands?

It is specific to the Scripter. See "Additional context" - using "Serialsend5" works as it should.
Or did i misunderstand you?

@gemu2015
Copy link
Contributor

scripter uses tasmota serial, 8E1 is only supported on hardware serial, however hardware fallback for hardware serial port 2 on ESP8266 was not initialized properly
try with this version

xdrv_10_scripter.ino.zip

@Dobie007
Copy link
Author

That solved the problem! Thanks for the quick response.
The Pico Serial decoder is happy now - no parity error anymore.

grafik

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

Successfully merging a pull request may close this issue.

3 participants