serial DAT callback as hex

my serial DAT returns bytes when I turn on the bytes column. What is the easiest way for me to see a column of same values in hex ?

You can select out that one column, and use an evaulate DAT to convert it to hex.
Or you could translate the message, in a python callback directly, and append the results to a FIFO DAT for example.

thnks.

I use :

hex(me.inputCell.val)

as my eval expression on selected column and it says that ‘str obj cant be interpreted as integer’. I guess that means that the bytes column is a list ?

hmm. I’m stumped.

tell me if I’m interpreting things correctly:

bytes column reports a byte array.
Eval DAT sees a byte array as a string.
built-in hex function only works on individual bytes (ints?).
Expressions dont work on arrays.
I need to apply an expression on each byte individually then reassemble as list.

seems like what im having difficulty with is that my bytes callbacks are arrays(per cell), not individual bytes.

My guess is that its trying to convert the “bytes” word in the top cell as well and failing.
Can you filter out that top row in your Select DAT ?

After playing around with this, here’s a single expression that works:

me.inputCell.val if not me.inputCell.val.isdigit() else hex(int(me.inputCell.val))

That is: convert string to int to hex, only if its composed of digits.

Attached is a small example that converts numbers to hex
(It uses udp instead of serial to have it functional on all systems)
decimal_to_hex.tox (1.25 KB)

thanks for looking at this Rob!

Included is a toe which hopefully maintains the callback content that i am getting.
i plugged my serialDAT et al into your solution but still cant get hex to print.
hopefully you can see the error I get:

'invalid literal for int with base 10 ‘255 255 253 0 1 7 0 85 0 6 4 40 66 221’ ’

(paraphrase , as I dont know how to make my MMB DAT error print to txt)
DynaMixelPingTst01.4.toe (4.39 KB)