EdgeTX / edgetx

EdgeTX is the cutting edge open source firmware for your R/C radio
https://edgetx.org
GNU General Public License v2.0
1.57k stars 334 forks source link

corrupted characters in getSourceName() #5177

Open offer-shmuely opened 3 months ago

offer-shmuely commented 3 months ago

What part of EdgeTX is the focus of this bug?

Transmitter firmware

Current Behavior

the name returned for some of the fields have additional invisible characters

firmSourceName = getSourceName(126) -- get SD name

we got firmSourceName as: 0xC2 0x8C 0x53 0x41

Expected Behavior

firmSourceName should be: 0x53 0x41

Steps To Reproduce

local i = 126
local expectedSourceName = "SD"
local firmSourceName = getSourceName(i)
print(string.format("source-id: %d, [%s](len:%d), [%s](len:%d) (is same: %s)", i, firmSourceName, string.len(firmSourceName), expectedSourceName, string.len(expectedSourceName), (firmSourceName == expectedSourceName)))
print(string.format("[%s] name as hex: %s", expectedSourceName, string.gsub(expectedSourceName, ".", function(c) return string.format("0x%02X ", string.byte(c)) end)))
print(string.format("[%s] name as hex: %s", firmSourceName,     string.gsub(firmSourceName,     ".", function(c) return string.format("0x%02X ", string.byte(c)) end)))

current result:

source-id: 126, [ŒSA](len:4), [SA](len:2) (is same: false)
[SA] name as hex: 0x53 0x41 
[ŒSA] name as hex: 0xC2 0x8C 0x53 0x41 

Version

2.10.1

Transmitter

FrSky X10 / X10S (ACCST) TX16s

Anything else?

this bug exist for long time the code that clean it: image

philmoz commented 3 months ago

0xC2 0x8C == CHAR_SWITCH (The switch symbol).

offer-shmuely commented 3 months ago

it does not work telemetry sensors as well, not only on switchs

source-id: 276, [“Cels](len:6), [Cels](len:4) (is same: false)
[Cels] name as hex: 0x43 0x65 0x6C 0x73 
[“Cels] name as hex: 0xC2 0x93 0x43 0x65 0x6C 0x73 
source-id: 276, [“Cels](len:6), [Cels](len:4) (is same: false)
[Cels] name as hex: 0x43 0x65 0x6C 0x73 
[“Cels] name as hex: 0xC2 0x93 0x43 0x65 0x6C 0x73
3djc commented 3 months ago

This one has telemetry symbol