Transformations

Hey.
I’m polling through modbus, and are getting a 16bit signed integer, in which the hi and low bytes are providing the ascii codes to the two-character string that I want to display.
I’m trying to make a transformation java script to do this, but I’m having trouble getting it to work.

I can seperate the high and low bit with something like:
var hi = (i >> 8);
var lo =(i & 0xFF);

This works nice enough to provide me with the two ascii numbers, but how do I convert them into a string? I’ve tried typecasting them, but it doesn’t seem to work.

Javascript has a method String.fromCharCode() that might work.

2 Likes

That worked - thanks!