Shop OBEX P1 Docs P2 Docs Learn Events
javelin stamp<=>pc serial communication specifications? — Parallax Forums

javelin stamp<=>pc serial communication specifications?

bearclawbearclaw Posts: 10
edited 2005-10-27 17:05 in General Discussion
Are the specifications for the serial communication between the javelin stamp and the PC documented and is this doc available?
I'm trying to port JavelinDirect to linux to be able to at least upload code from linux, and the specs would realy help...

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-10-20 20:25
    You find sources for JavelinDirect here.
    v1.0 is the original
    v1.2 is my adaptation to be able to create and download jem-files
    (so customers don't require your source files for downloading to the javelin)
    http://groups.yahoo.com/group/JavelinCode/files/JavelinDirect/

    I do not know of existing documents, but the protocol is easily
    extracted from the source files. The download is done by

    void __fastcall TSXComm:[noparse]:D[/noparse]ownloadJemFile( char *jemData, int length, bool debug )

    in file TSXComm.cpp

    Best to check out v1.2 main.cpp which shows how the command line options are handled.

    regards peter

  • bearclawbearclaw Posts: 10
    edited 2005-10-21 22:41
    Hmm, I can't get my communication right. The javelin sends me FF FE instead of 0F 0E upon reset, echoes everything I send right but doesnt respond to commands.
    I certainly got some serial parameters wrong.
    What is the serial baud rate used by javelindirect/IDE? I wasn't able to find where it was set in the code.
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-10-21 23:07
    The javelin uses 28800 baud for its JIDE port. At
    http://groups.yahoo.com/group/JavelinCode/files/documents/
    you find the protocol used for communication with the Jide message window.
    The protocol to download a new program to the javelin also uses 28800
    baud and is available as source code in the javelindirect package.

    My adapted version of the jide message window (that filters out echoes)
    http://groups.yahoo.com/group/JavelinCode/files/JideTerm/
    versions for dos and windows.

    The baud is specified by a line
    ·

    Port->ComPortSpeed = br28800;

    in the javelindirect main.cpp file.

    regards peter


    Post Edited (Peter Verkaik) : 10/21/2005 11:11:39 PM GMT
  • bearclawbearclaw Posts: 10
    edited 2005-10-22 00:32
    Oops, is it possible to dammage the javelin chip(either physically or by erasing the code handling the JIDE port on the chip) by sending "wrong" data on the JIDE port?
    I tryed to send random data to see if my mid-upload stall was data-dependant or not, and since then I can't even start the upload procedure properly....
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-10-22 01:28
    The code that handles downloading and communication is programmed into

    the sx48 that is on the javelin module. You can not overwrite that.

    Can you still identify the javelin (project->identify) and test the

    connection (project->test connection) ?

    regards peter
  • bearclawbearclaw Posts: 10
    edited 2005-10-24 18:25
    identify gives me: version $50 loopback yes echo yes got status no
    test connection outputs:

    Found connected Javelin...
    Resetting
    TXComm: QueryStatus
    TSXComm: SendCommand(1)
    [noparse][[/noparse]ERROR IDE-0009] Error communicating over the serial port(checksum failed)
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-10-24 18:55
    ·
    Here is the IDE0009 error:
    Error communicating over the serial port (checksum failed):
    ·[font=Arial,Arial size=2]The received data was corrupted. [/font][font=Arial,Arial size=2]Verify a good cable connection[/font]
    Looks like your javelin is ok.
    Please turn off the com port fifo in your pc.
    That sometimes helps.
    Can you post your main.cpp file for your application?
    regards peter



    Post Edited (Peter Verkaik) : 10/25/2005 12:52:25 AM GMT
  • bearclawbearclaw Posts: 10
    edited 2005-10-24 23:20
    >Looks like your javelin is ok.
    I hope your'right, but you may be too optimistic here... :/
    Disabling FIFO on serial port has no effect. Everything was working fine on this configuration before.
    I join you jemtx.cpp, the code compiles on linux, and is supposed to take a .jem file as first argument, and upload it to the stamp.
    It stalls after a fixed number of 19bytes packet though (timeout receiving ack)
    When I tryed to upload /dev/urandom, it stalled as well, but since then I have the problem described in my previous posts.
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-10-25 00:51
    Here is message once posted in the thread

    Is the javelin worth it?

    The message is by Magnus Lundin.

    He created a linux downloader. The yahoogroup he posted it on is no more

    and unfortunately I have no copy. Perhaps someone has.

    The post:

    It is possible to edit, compile, link and upload programs to the Javelin from Linux.
    It is also possible to control start/stop/singlestep programs running on the
    Javelin from Linux.
    It is not possible to get full debug support linking the executing code
    on the Javelin to the Java source code. If parallax publishes more tech info on their linker,
    and sombody has the time, then this should be doable.

    The compiler ( jikes v 0.4.7 ) can be run under wine and can also be compiled
    into a native Linux app, but the old code must be slightly patched before it compiles with a
    modern c++ compiler ( I use gcc 3.3.3 ). Sun njava compilers or newer versions of jikes
    does not seem to work.

    The linker , JavelinDirectL , is supplied by Parallax in Linux version on the yahoo file area.

    I wrote a downloader and run controi in python using the Parallax c++ code as a base.

    I created a raw but working package - javelinLinux.zip
    and posted it to the old yahoo file area some months ago
    http://groups.yahoo.com/group/javelinstamp/files/

    There has been no response so I havnt put any effort into updating this package yet.

    Magnus Lundin



    Magnus Lundin has posted 1 post in total (so this is it) and no email address in his profile.

    From what I see in your main.cpp file, I get the feeling the timing is way off.

    The windows version uses quite a lot of different delays.

    Why not keep the original layout and only change the code to open a serial port?

    regards peter
  • bearclawbearclaw Posts: 10
    edited 2005-10-25 14:44
    Interesting,
    My .jem file was generated by a linux version of javelinDirect, the class files were generated by a linux jikes (debian package) which seems too recent (class version number does not match with what javelindirect expects, I hacked the test to see if this would still work).

    But my guess is this is not the problem, as the upload does only upload the file without any checking on its content. Am I wrong?

    I tryed first to integrate into javelindirect, but had many problems so I tryed to extract the upload code in nominal conditions for testing.
    Besides, doing a "while (!charAvailable()) ;" to wait for a chat on the serial port seems quite ineficient, using a select call is much better.

    As for timing, the values are only timeout delays, not sleep, so I don't think it matters. There may be a timing problem with my code though: I read the file on the disk chunk by chunk, so there may be a "high" delay between two successive chunks, this may be a problem for the stamp.

    I would try to read the whole file first into memory....if I could get my stamp to work again [noparse]:([/noparse]
    I'll keep trying.
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-10-25 15:14
    The time I updated the source (for windows) I did load a char array with the entire jem file,

    plus an additional 20 bytes. According to the original sources there is an issue about the

    true end, hence an additional 18 bytes (I took 20) must be appended.

    Here is the code I used to read in the jem file.

    ····· /*
    ······ * Read the .jem file.
    ······ */
    ····· strcpy(FileBuffer, FileName);
    ····· strcat(FileBuffer, ".jem");
    ····· jemFile = fopen(FileBuffer, "rb" );
    ····· if (!jemFile)
    ······· throw EError(kIDE_ERROR, 17, FileBuffer, errno, _sys_errlist[noparse][[/noparse]errno] );
    ····· fseek(jemFile,0L,SEEK_END);
    ····· length = ftell(jemFile);
    ····· fseek(jemFile,0L,SEEK_SET);
    ····· jemData = (char *)malloc(length+20L);
    ····· for (int i=0; i<length; i++) {
    ······· jemData[noparse][[/noparse]i] = (char)fgetc(jemFile);
    ····· }
    ····· for (int i=length; i<length+20L; i++) {
    ······· jemData[noparse][[/noparse]i] = (char)0;
    ····· }
    ····· fclose(jemFile);

    I remember having trouble if those 18 or 20 bytes were not present.

    Once the jem file was in the array, I could simply call the download routine.

    regards peter
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-10-25 15:44
    You are wrong in that the packets are not checked, just uploaded.

    Each packet (19 bytes total, 16 bytes data) must be acknowledged, according to the download routine:

    void __fastcall TSXComm:[noparse]:D[/noparse]ownloadJemFile( char *jemData, int length, bool debug ) {
    ·unsigned char packet[noparse][[/noparse]19];
    · int pLength = 19, packetStart = 0;
    · int firstPacket = 1;

    · if ( gOptions.debugComLevel >= kDebugComFunctions )
    · ·StatusDebug("TSXComm:[noparse]:D[/noparse]ownloadJemFile(%d)", length);

    · // Check that the SX is ready to accept a download.
    · SendSimpleCommand(kComDownloadOK);

    · if ( debug )
    · ·jemData[noparse][[/noparse]0] = kDebugMagic;
    · else
    · ·jemData[noparse][[/noparse]0] = kRunMagic;

    · printf("Downloading ");
    · for ( int i = 0; i < ceil(length/16.0); i++ ) {

    ··· // Only do the update 20 times.
    ··· if ( i%(int)(ceil(length/16.0)/20) == 0 ) {
    ····· printf(".");
    ····· fflush(stdout);
    ··· }

    ··· /* TODO: This reads past the end of the jemData array. Need to handle the end case properly. */
    ··· memcpy(&packet[noparse][[/noparse]2], jemData+packetStart, 16 );

    ··· packet[noparse][[/noparse]0] = kComProgram;
    ··· packet[noparse][[/noparse]1] = firstPacket;
    ··· packet[noparse][[/noparse]16+2] = ComputeChecksum(packet, 16+2·);

    ··· // Send the command.
    ··· SendPacket(packet, 16+3);

    ··· firstPacket = 0;
    ··· packetStart += 16;

    ··· // Programming the EEPROM may take more time than usual for the Ack.
    ··· // Use an increased timeout.
    ··· ReceiveAck(kComProgram, kProgramWait);
    · }
    · printf("\n");

    }

    void __fastcall TSXComm::ReceiveAck(int command, int wait )
    {
    · // Wait for acknowledgement.
    · int charTime = GetTickCount(), endTime;
    · unsigned char c;

    · while ( charTime + wait >= GetTickCount() ) {
    ··· while ( !CharReady() ) {
    ······· if ( charTime + wait < GetTickCount() )
    ········· throw EError(kIDE_ERROR, 22 );
    ··· }
    ··· endTime = GetTickCount();

    ··· c = GetChar();

    ··· if ( gOptions.debugComLevel >= kDebugComBytes )
    ····· StatusDebug("TSXComm::received byte $%2.2X '%c' in %dms", c, isprint(c)?c:'.', endTime-charTime);

    ··· if ( c == (unsigned char)((unsigned char)command|kReplyBit) )
    ····· return;

    ··· // We just got an asynchronous message. We can't deal with it here so
    ··· // pretend we just received a one byte packet and queue it for later.
    ··· HandlePacket(&c, 1, Linker);
    · }

    · // We didn't get the reply we expected within the timeout.
    · throw EError(kIDE_ERROR, 22 );
    }

    regards peter
  • bearclawbearclaw Posts: 10
    edited 2005-10-26 09:35
    Yeah my code waits for the ACK, my question was more: does the stamp check the content of the data during the upload, (jem header, class version number, ...) or does it just stores the jem in rom?
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-10-26 13:29
    I assume the javelin·calculates the checksum for each packet,

    but really only Parallax could tell how the javelin handles

    the program download.

    regards peter
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-10-27 17:05
    Here is a protocol example file written in javelin java.

    Your pc program must handle communication in a simular way

    to comply to the protocol. This is just runtime communication,

    not for downloading new programs to the javelin.

    regards peter
Sign In or Register to comment.