0

Text to integer

Marcel 7 months ago in IQANdesign updated by Gustav Widén (System support) 7 months ago 12

Is it possible to convert text to integer? I would like to exchange the serial numbers (Module Diagnostic) of the hardware through the CAN bus. I believe the serial numbers are max 4 bytes in integer(hex) number. If I want to send them as text, I need longer CAN messages (>8 bytes). It will also be easier for the external system (no Parker system) that is supposed to read these values . I use a MD4 and MC41.

+1

If you're using IQAN 5, you can use the JTOUT (J1939 Text Out) channel.  In IQAN 6, there are TPOUT (text parameter out) channels that you can used which add some flexibility.

Thanks for your reply. I know about the TPOUT (I use iQan6), but how to convert the TPOUT to an integer value?

The TPOUT channel will convert the string to ASCII values.  The receiving device would need to convert the ASCII values back to the text.

Ok, but then I need 10 bytes instead of 4 bytes if I can convert it to an integer value. That makes it difficult on the receiving device. Is there no way to convert the text value to an integer value?

Is it the Serial of the IQAN module you want to send over CAN? I think they comes as Real value when using Module Diagnostics. And if you want that number as integer its a matter of rounding it.

The value type of S/N Module diagnostic channel is text. (the MDGN channel has different value type depending on what value you read with it)

Thank you for your replies!

Ok, so there is no way to convert the text value to an integer value? (Or get the serial number as number (integer/real))?

The least effort in the IQAN project is to make use of the J1939 COMPID. When another device sends a request for PGN 65259, the response from the IQAN module will include SN. 

But essentially that is the same as the method Ed suggested, the IQAN module will send a text string in a multi-packet message. 

To convert the text to an integer, you'd need some string handling function. There have been a number of requests for this, see this post here

Ok, thank you Gustav. It's clear now. I have to wait until there is a solution in iQan Design. I voted for your post, so maybe this helps :-).

Gustav, can a "Frame out" be looped back to a "Frame In" on the same Master via the CAN-Bus? Just thinking, If sending as Text and looping it back to Integer parameters the Text will be converted to ASCII values and from there is just a matter doing some math.

I think this classifies as a "Hack" not a proper solution.

Interesting idea for a hack Jonas.. It won't work on the same bus though. To read a frame out sent on one bus, you need to use a second CAN controller (another bus in the system layout) and wire the two together.