Shop OBEX P1 Docs P2 Docs Learn Events
Serial communication PC <--> Javelin — Parallax Forums

Serial communication PC <--> Javelin

Robot FreakRobot Freak Posts: 168
edited 2009-04-17 17:20 in General Discussion
I'm trying to communicate with the Javelin using a RS232 DLL.

When I try, I see no flashing light on my RS232 to USB adapter when I turn the Javelin on,
When I open the Javelin IDE, then turn the Javelin on, it starts flashing.

Is there any signal I've got to send to the Javelin to let it know the computer is connected?
I've used the following values:
Baud rate: 9600
Byte size: 8
Parity: 0
Stop bits: 1
Read timeout: 0
Write timeout: 0

Thanks,
Robot Freak

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2008-01-17 23:05
    How exactly is the pc connected to the javelin?
    From your baud parameters, it looks you try
    to communicate via javelin I/O pins and a levelshifter,
    like using the COM connecter on the javelin demoboard.
    If you use the programming port (JIDE of the javelin
    demoboard), that only supports 28800 baud and
    requires a special protocol.

    regards peter
  • Robot FreakRobot Freak Posts: 168
    edited 2008-01-18 09:16
    I am trying to use the programming port, so i've got to use 28800 baud, right?
    What special protocol does the Javelin require in order to get Terminal.getChar and System.out.print working?

    Kind regards,
    Robot Freak
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2008-01-18 09:52
    Here is a description of that protocol:

    What is the protocol used to send messages to and from the Sin and Sout pins?

    Debug messages sent from the Javelin conform to the following pattern:

    0x05 0x03 <messagedata> 0x7E

    <messagedata> is the sequence of bytes being sent by the CPU.message() native method. It is byte-stuffed. This means that if <messagedata> contains a byte <b> that has the value 0x7F or 0x7E then that byte is replaced with 0x7F <b>^0x20. i.e. 0x7F followed by the orginal byte xored with 0x20.

    Terminal characters are sent to the Javelin using the following algorithm:
    1. When it is ready to receive a byte (the Terminal.getByte() native method is called) the Javelin transmits 0x11 out Sout.
    2. If the terminal has no data to send to the Javelin it replies with 0x13.
    3. If the terminal has a byte <b> to send, then it replies with 0x12 <b>.

    After the Javelin is reset it send 0x0F followed a pause followed by 0x50 (the version of the Javelin firmware).

    Running the following simple program:

    public class HelloWorld { public static void main() { System.out.println("Hello World"); } }

    will generate the following on Sout:

    0F 50 05 03 48 65 6C 6C 6F 20 57 6F 72 6C 64 7E 05 03 0D 0A 7E 05 05 7E

    Note that the sequence 0x05 0x05 0x7E indicates that the Java program has ended.


    What is important, is that your pc program must wait for 0x11 (javelin ready to receive a byte),
    and that ANY byte sent to the javelin is echoed.
    Attached is an example program (in javelin java) that demonstrates how you can implement
    this protocol on the pc. It uses a statemachine. Also attached is a test program that you
    download to the javelin. It assembles a textcommand and then prints the command
    to the messagewindow. It is only tested with Javelin IDE version 2.0.3


    regards peter
  • jmspaggijmspaggi Posts: 629
    edited 2009-04-17 14:36
    Hi,

    I know it's an old thread, but I'm trying to connect the Javelin Terminal to a Linux server in order to store the output and I'm having some troubles.

    I can configure the com port to be 9600, 19200, 38400, etc. But not 28800. So I'm seeing some information coming, but I'm not able to parse them. Is there a way to modify the terminal in order to have it at 19200 or 38400? Or should I configure the server at 38400 and use a specific protocol in order to be able to transform the flow?

    Thanks,

    JM
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2009-04-17 15:05
    Unfortunately, no.
    The javelin firmware uses 28800 (they really should have selected 19200
    which is much more common) and cannot be altered.

    Take a look at Javelintools (for linux):
    http://sourceforge.net/project/platformdownload.php?group_id=189174


    regards peter
  • jmspaggijmspaggi Posts: 629
    edited 2009-04-17 15:10
    Hi Peter,

    Thanks for your prompt reply. I'm also trying to see with HyperTerminal (Windows) and I have the same issue. It's not able to set 28 800. Is it possible to link HyperTerminal with the Javelin? How? I tryed 19200 8N1 and 38400 8N1 with no success. Maybe 8N1 is not right?

    Thanks for you help.

    JM
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2009-04-17 15:15
    For windows, you can use my stand-alone JideWin Terminal,
    that lets you save message window output to a file.

    http://tech.groups.yahoo.com/group/JavelinCode/files/JideTerm/

    You can also use the IDE beta, that also lets you save message window
    output to a file.

    regards peter
  • jmspaggijmspaggi Posts: 629
    edited 2009-04-17 17:20
    Hi Peter,

    After a lot of tries, I'm finally able to make it works under Linux.

    Just in case someone else is looking for it:

    setserial /dev/ttyS0 baud_base 115200 spd_cust divisor 4
    stty -F /dev/ttyS0 38400
    
    



    Where /dev/ttyS0 is your serial port.

    And on the Java side, you need the javax.comm API.

        public TestPort() {
            try {
                serialPort = (SerialPort) portId.open("SimpleReadApp", 2000);
            } catch (PortInUseException e) {}
    
            try {
                inputStream = serialPort.getInputStream();
            } catch (IOException e) {}
    
            try {
                serialPort.addEventListener(this);
            } catch (TooManyListenersException e) {}
    
            serialPort.notifyOnDataAvailable(true);
    
            try {
                serialPort.setSerialPortParams(38400, SerialPort.DATABITS_8,
                                               SerialPort.STOPBITS_1,
                                               SerialPort.PARITY_NONE);
            } catch (UnsupportedCommOperationException e) {e.printStackTrace();}
    
            readThread = new Thread(this);
    
            readThread.start();
        }
    
    



    This is just a re-use of the simple sample provided with the Sun API.

    Now I still have to parse the data based on the protocol (headers, Javelin Ready, etc.) but it's on the good way [noparse];)[/noparse]

    Thanks,

    JM
Sign In or Register to comment.