Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

Receiving raw hex or binary from serial port in Linux shell

Status
Not open for further replies.

mrkenneth

Electrical
Aug 26, 2004
79
0
0
CA
I am working with some AXIS network cameras (namely the AXIS 221 and the AXIS 2420). The cameras contain a web server using an ETRAX 100(LX) CRIS processor running ELinux. I can use Telnet to access the shell (mish) as root.

I would like to interface a Dallas Semiconductor 1-Wire temperature sensor (most likely the DS18B20) via the serial port. I am using the DS9097U-009 RS-232 to 1-Wire adapter as the interface between the camera and the temperature sensor. The adapter contains a DS2480B serial 1-Wire line driver.

I am able to successfully transfer commands to the 1-Wire adapter using:
[tt] echo -n "\[three-digit octal number]" >/dev/ttyS1[/tt]

Incidentally, the following does not output the intended hexadecimal number:
[tt] echo -n "\x[two digit hexadecimal number]" >/dev/ttyS1[/tt]
It outputs [tt]\xFF[/tt]. But I have already converted all of the required 1-Wire commands to octal.

The temperature sensor outputs a 16-bit code through the 1-Wire adapter to represent the temperature. However, I cannot seem to find a way to receive the raw 16-bit number. I am currently using the following command to receive the data:
[tt] dd if=/dev/ttyS1 bs=1 count=2[/tt]

The input is converted into ASCII before being displayed or saved. How can I receive the 16-bit number that I can later convert to a decimal number?

Thank you in advance!

P.S. I have not had much experience with Linux. Most of my programming has been for Microchip PIC microcontrollers.

---------------------------------------------------------
Operation Radiation:
 
Replies continue below

Recommended for you

Hiya-
Turn off the canatonical processing of the incoming serial
data stream and use the read function to read the 4 bytes
of data. Optionally, you might have to read the carriage
return and line feed (so the read will be 6 characters in
length, not four). Then it is a simple procedure to
convert the binary to hex, octal, or whatever.

You might want to point your browser to:


and/or


and, although I haven't looked at it in detail you might
also like:



Hope that these help!


Cheers,

Rich S.
 
Status
Not open for further replies.
Back
Top