LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Interfacing with devices (https://www.linuxquestions.org/questions/programming-9/interfacing-with-devices-464712/)

worldgnat 07-16-2006 10:55 PM

Interfacing with devices
 
I'm trying to interface with several devices such as an IR dongle and a serial/usb connection, and I was wondering how I would to that. Basically, I have two medical devices that store data, and I need to get the data out. Is there some way I could connect, and then blindly plod along to get it to release the data, or is there some standard communication language that I could use. Basically, any way to get the data that's stored in the device out would be very, very helpful.

Thanks,
-Peter

firstfire 07-16-2006 11:36 PM

Hi, worldgnat.

What says `dmesg' about your device ( `dmesg|tail' ) ? What type of device you try to connect? Which cable you use (for example Profilic PL2303 USB/Serial converter)?
Provide more information please.

In general, if driver for your device is correctly installed, then your device represented in your system as "/dev/something" file.
The second case is serial devices. In this case you could connect with device via
Code:

/dev/ttyUSB0
(usb/serial) or
Code:

/dev/ttyS0
(real COM1 serial port) files. You have to find program which know about protocol used in connection if there is no special driver.

cs-cam 07-16-2006 11:41 PM

minicom is a nice little app for communicating over serial connections, might be worth having a look at that rather than have a tail -f /dev/ttyS0 in one window and echo'ing commands to the device in another ;)

worldgnat 07-17-2006 03:44 PM

Ok, I've ordered an rs-232 to usb converter that I'll need, and once I get it (in a day or two with any luck), Edit: I'm going to try an IR dongle via serial on a desktop (I was waiting because my computer doesn't have a serial port.) By the way, the device is an Animas IR 1000 insulin pump. Another is a blood glucose testor. Please let me know if you have any insite.

Thanks,
-Peter

worldgnat 07-17-2006 07:23 PM

Ok, I tried the tail -f /dev/ttyS0 and echo method, and I got something to work. now when I echo to /dev/ttyS0 the little red LED on top of the dongle flashes. No change in the insulin pump or the out of tail -f /dev/ttyS0 though. I guess we're just not speaking the same language. I tried "help", "command", and "commands". No output what so ever. Minicom seemed to only want to initiate the modem, and not connect via serial port. It's a step in the right direction. Any ideas?

Thanks,
-Peter

jlinkels 07-17-2006 09:44 PM

worldgnat,

Devices like this use a protocol. It means that you have to ask something in a specific way, and you get an answer in a specific format.

There are a million standard formats (http, ftp, telnet, something to talk with the computer in your car) and a zillion proprietary formats.

A number of formats is binary and they use special codes like DLE, STX and other codes < 0x20. Some other formats are pure ASCII so it is easy to recognize the messages using an analyzer. Then other formats use binary control characters, but ASCII as message body.

If you have something standardized, sometimes you can issue a command, like "help". Sometimes devices (like routers) can speak http over serial so you can connect a web browser.

Summarizing, if you have a device of brand X, you really need to know the protocol that is being used. Only then you can do meaningful requests, and interpret the results accordingly.

jlinkels

worldgnat 07-17-2006 09:46 PM

Makes sense. I was just hoping it would be something easy :). I'm going to try to contact my local sales rep tomorrow and see if he can get someone to talk to me about how to communicate with the device.

Thanks,
-Peter

worldgnat 07-17-2006 10:02 PM

I was thinking: is there any way to hack this? I guess not, but how do people discover the protocol that each device uses?

Thanks,
-Peter

Wim Sturkenboom 07-17-2006 11:23 PM

You need a working system to 'hack' the protocol. If your device e.g. comes with windows drivers and software, you can setup a windows box. Next you can 'snif' the communication using one of the following methods:
1)
Hook an oscilloscope on the relevant lines (data/clock; not sure which lines there are for USB) and see what goes over the lines when you press buttons etc. This is definitely the hard way but somtimes the only one).
2)
You can look for some sniffer-software on the internet that will display the data on the relevenat lines. Do a search for 'USB sniffer' or 'USB monitor' on the internet.

In both cases, you need to analyze what you see and get the protocol out that way.

worldgnat 07-17-2006 11:35 PM

I'll try the company first, but then I'll probably try to figure out the protocol via the method you mentioned just to learn how to do it. It sounds complicated, but it sounds like it would be a good skill to learn.

Thanks,
-Peter


All times are GMT -5. The time now is 04:37 PM.