Shop OBEX P1 Docs P2 Docs Learn Events
Serial communication between Java and BS2sx — Parallax Forums

Serial communication between Java and BS2sx

ArchiverArchiver Posts: 46,084
edited 2003-04-27 00:56 in General Discussion
Hi,
I'm trying to send data from a BS2SX to a Java program
running on Windows 98 (also tried on a ME machine)
that uses the javax.comm APIs to listen to the serial
port. I seem to be able to open the port without
problems, but the problem is that I never receive any
data from the BS2SX.

The command I use to send data from the BS2SX is:
SEROUT 16, 16624, [noparse][[/noparse]STR resout\6]
where resout is a 6 byte array.

The program that I use to read data is the SimpleRead
example that is included in the Java Communications
API package with the following serial port
parameters:
serialPort.setSerialPortParams(9600,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);

Has anyone else run into this problem? Should I perhaps
go ask in the javelinstamp forums as well?

I've been banging my head against this problem all day
and would really appreciate a solution.

William

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-04-26 20:21
    You might want to break things down a step at a time. You can make sure the
    Stamp parameters are correct by sending a test string in a loop that you can
    watch on your PC using a known-working terminal program. Once you know that
    the Stamp is sending what you want at the baud-rate you desire, then you can
    start working on your Java program.

    Just keep in mind that if you send something from the PC to the Stamp via the
    programming port (pin 16), the Stamp will echo it back so your PC program
    must be prepared to deal with this.

    -- Jon Williams
    -- Parallax


    In a message dated 4/26/2003 1:30:39 PM Central Standard Time,
    william@s... writes:

    > Hi,
    > I'm trying to send data from a BS2SX to a Java program
    > running on Windows 98 (also tried on a ME machine)
    > that uses the javax.comm APIs to listen to the serial
    > port. I seem to be able to open the port without
    > problems, but the problem is that I never receive any
    > data from the BS2SX.
    >
    > The command I use to send data from the BS2SX is:
    > SEROUT 16, 16624, [noparse][[/noparse]STR resout\6]
    > where resout is a 6 byte array.
    >
    > The program that I use to read data is the SimpleRead
    > example that is included in the Java Communications
    > API package with the following serial port
    > parameters:
    > serialPort.setSerialPortParams(9600,
    > SerialPort.DATABITS_8,
    > SerialPort.STOPBITS_1,
    > SerialPort.PARITY_NONE);
    >
    > Has anyone else run into this problem? Should I perhaps
    > go ask in the javelinstamp forums as well?
    >
    > I've been banging my head against this problem all day
    > and would really appreciate a solution.
    >
    > William



    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-04-26 21:13
    --- In basicstamps@yahoogroups.com, jonwms@a... wrote:
    > You can make sure the Stamp parameters are correct by sending a test
    > string in a loop that you can watch on your PC using a known-working
    > terminal program.

    Well, the Basic Stamp Editor's debug window receives everything that
    the Basic Stamp generates and sends just fine, but the Windows
    HyperTerminal doesn't show anything when I connect it directly to the
    same com port with the same baud rate, stop bits, parity and without
    flow control.

    > Just keep in mind that if you send something from the PC to the
    > Stamp via the programming port (pin 16), the Stamp will echo it
    > back so your PC program must be prepared to deal with this.

    My app never needs to send anything to the BS2SX so this is not really
    a problem. However, when I do make my app or HyperTerminal send
    something to the BS2SX for testing purposes, I receive echos from that
    transmission in both applications (as well as in another terminal
    application that I have tried). I just don't receive the data that
    the Basic Stamp itself generates and sends, that data only appears in
    the Basic Stamp Editor's debug window.

    Thanks for answering.

    William
  • ArchiverArchiver Posts: 46,084
    edited 2003-04-27 00:56
    Ok, I finally figured it out. I apparently happen to use
    the only programming board that does not have the DTR flag
    connected to ground so I had to manually set it low using
    software to get it to work. I'm currently using the BS2
    Carrier Board, but I had only used the BOE in the past.
Sign In or Register to comment.