Hallo,
ich muss einen Modbus ab Register 3821 für 7 Bytes auslesen, Rückgabewert ist CHAR (oder halt String mit 7 Char). Die Daten liegen als HEX vor und sind zudem gedreht:
scan-h03821 hex=3034, string=04, s=13360, s>=12340, S=13360, S>=12340
scan-h03822 hex=3143, string=1C, s=17201, s>=12611, S=17201, S>=12611
scan-h03823 hex=3646, string=6F, s=17974, s>=13894, S=17974, S>=13894
scan-h03824 hex=3532, string=52, s=12853, s>=13618, S=12853, S>=13618
scan-h03825 hex=3245, string=2E, s=17714, s>=12869, S=17714, S>=12869
scan-h03826 hex=3542, string=5B, s=16949, s>=13634, S=16949, S>=13634
scan-h03827 hex=3830, string=80, s=12344, s>=14384, S=12344, S>=14384
Statt "04" müsste "40" kommen, statt "1C" müsste "C1" kommen. Aktuell lese ich sie mit "unpack H*" aus, dann bekomme ich HEX. Wie komme ich jedoch auf ASCII bzw Char? Per Source bekomme ich das hin, aber geht das auch automatisch?
Hallo,
schau Dir mal dieses Attribut an, da könntest Du auch mit Perl convertieren.
obj-[cdih][0-9]+-expr
In master mode this defines a perl expression that converts the raw value read from an external slave device into a value that is stored in a Fhem reading.
In slave mode this defines a perl expression that converts the raw value written from an external master device into a value that is stored in a Fhem reading.
Inside the expression you can use $val to get the value or the array @val in case there are several values (e.g. when unpack produces more than one value)
Example: attr MBTest obj-h225-expr $val * 2
Um die Register zu vertauschen gibt es dies hier
dev-h-defRevRegs 1
VG Christian