Reading a Hex string

steve holmes's picture

On my continuing adventure of PTZ camera control with serial I am trying to read the serial responses from the camera. When I query the camera position I should get a hex string back from the camera but I get this in return "êAˇêQˇ" so any ideas what I need to convert this to a hex string.

Thanks again for all the help.

Cheers Steve

cwright's picture
Re: Reading a Hex string

QC has no notion of "hex strings" (byte streams) -- the closes approximation is a normal text string.

You can use javascript to emit hex stuff from the text string using string.charCodeAt(index) on each character in the string. it will probably lose some bytes though (0x00, in particular, isn't really representable in a text string).

steve holmes's picture
Re: Reading a Hex string

If javascript is liable to lose bits what is the best way to process this type of data? I am making a request to the camera for its current position so I can use this to create software based 'presets' that can store the cameras PTZ values so that I can have more than just the 6 memory 'presets' that come with the camera. Cheers for the help. Steve

cwright's picture
Re: Reading a Hex string

there isn't one -- it's not JS that loses bis, but the conversion from hex string to text string that the serial patch does -- there isn't a way to handle unstructured binary data in QC, so the only lossless alternative is a structure (images would be in the running if color correction didn't cook data all the time).

steve holmes's picture
Re: Reading a Hex string

Please forgive me constant questioning, so because QC has no way to work with binary data there is no effective way for me to read the feedback from the camera, is that correct? Cheers Steve