5

I'm going to need to integrate a Java application that I wrote with a medical device that uses a serial port for communications. This device is rather expensive, and also not so portable.

I'd like to be able to test code wherever I happen to be, but you can only do so much before you need to plug in your serial device and start testing.

So, I'm looking for a cheap, portable electronic device that uses a serial port for communication. It only needs to communicate one way (i.e. I only need to collect data from it). In this way, I can be sitting at my local coffee shop, plug in my serial to USB connector, hook up this mystery device, and start receiving data.

EDIT:
For those interested in my strange predicament, I'm connecting to a Tanita scale TBF-300A
web site
Communication Standard: EIA RS-232C Compatible
Communication Method: Asynchronous
Baud Rate: 2400bps
Data Length 7bits
Parity: EVEN
Stop Bit: 1bit

Someone scans a barcode, steps on the scale, and my program feeds the info into a database like this:
adobe air -> blazeds -> java -> hibernate/spring -> HSQL db file

My guess is that I'm going to write a java app that takes the serial port information and redirects it to a TCP port that my air app can listen to. This is my guess, for now.

Stephano
  • 5,716
  • 7
  • 41
  • 57
  • Is that device using the TAP protocol by any chance? – Freiheit Oct 01 '10 at 18:41
  • @Freiheit No, but TAP certainly looks interesting. See above for more info. – Stephano Oct 01 '10 at 18:57
  • 1
    We're drifting off topic a bit but I did some similar work. I built a Java daemon to handle the serial communications and get ALL of the data from the serial device for a given transaction at once and then made a REST webservice call to my application to actually process and store the actual data. If you can capture your data in one go this is a better model. If you need to like confirm the barcode with an ACK you might need something a little more chatty. RXTX is a good serial library: http://rxtx.qbang.org/wiki/index.php/Main_Page – Freiheit Oct 01 '10 at 20:35
  • @Freiheit Thanks for the link. The fun part about Adobe Air is that I can use the TCP socket support to listen on some port. This way I can validate the barcode, tell them to step on the scale, and my Java app would forward the data on to that specific TCP port. I think. These are guesses. Are there any Java libraries you would recommend for serial port chatting? – Stephano Oct 01 '10 at 20:45
  • RXTX is good for any use case. The "chatter" I mentioned comes in with using webservices rather than any particular serial library. I think the overall app design gets into a whole new question. For the question you asked, use RXTX as your Java lib and a serial port emulator suggested in the comments. – Freiheit Oct 04 '10 at 14:17

4 Answers4

6

You might want to look at com0com. This lets you create virtual COM ports on your computer and connect them together in pairs. With this, you can write a small test application that emulates the behavior of your "mystery device" and writes data to one of these virtual COM ports, and have your other application read data from the other COM port.

With this setup you can do any testing that does not require plugging the actual medical equipment, without purchasing any external device. To your application it will look like a real COM port.

Edit:

com0com is Windows-only, but here are some alternatives for non-Windows platforms:

Grodriguez
  • 21,501
  • 10
  • 63
  • 107
  • Interesting idea... I'm programming on a Mac and my other machine runs Ubuntu. Would this still work for me? – Stephano Oct 01 '10 at 18:12
  • 1
    com0com itself is Windows-based, but you can do the same on Linux (e.g. http://www.dest-unreach.org/socat/) and Mac (e.g. http://members.iinet.net.au/~mgl/MartysPlace/MultiCom.html). – Grodriguez Oct 01 '10 at 18:16
1

You might look at some sort of Microcontroller dev board. An Arduino or an MSP430 probably would fit the bill. You will need to write a small amount of code for it, but you could get it to send exactly what you want.

Philip Tinney
  • 1,986
  • 17
  • 19
1

Do you need to actually have an external hw device... can you get away with using a serial port emulator (ex: http://com0com.sourceforge.net/)?

chrismh
  • 131
  • 4
0

I'm pretty sure that you have a computer already!

There are usb to serial cables which might do the trick. Just loop from your own motherboard serial port to a usb port.

Eric
  • 19,525
  • 19
  • 84
  • 147
  • I've got a USB to serial cable, but I don't have a portable device that will send information down that cable to my computer. That's the part I want to test, receiving the information. – Stephano Oct 01 '10 at 17:51