I was writing this answer on tech-talk 7 hours ago....
~Ralph
-------- Original Message --------
Dear all,
I am trying to communicate a serial device using
StreamDevice-2-3 on 32-bit Linux OS. writting values using
the following protocol:
!Innn<cr> (program mA demand. FFF=10mA, nnn
must be 3 hexadecimal digits)
Reading values using the following protocol:
?I<cr> , and the response is ?Innn. nnn
represents the hexadecimal.
How can I convert decimal to hex when sending value ,and
how can I convert hex to decimal when receiving value?
Thanks,
Demin zhang
Hello Demin,
Please refer to the StreamDevice doc that explains the formats
[1].
There you will find that the %x and %X converters are converting
LONG values from and to hexadecimal digits.
In addition to the hex encoding done by the format converters in
StreamDevice, you will have to add Linear Conversion to the ai and
ao records you use, converting engineering values (0...10) to raw
values (0...4095) and vice versa. (ESLO=0.002442 and LINR=SLOPE
should do that. See [2] for details.)
Hope this helps,
~Ralph
[1]
http://epics.web.psi.ch/software/streamdevice/doc/formats.html
[2]
https://wiki-ext.aps.anl.gov/epics/index.php/RRM_3-14_Analog_Output