Shop OBEX P1 Docs P2 Docs Learn Events
Javelin Direct Source Code now available under GNU Public License! — Parallax Forums

Javelin Direct Source Code now available under GNU Public License!

Ken GraceyKen Gracey Posts: 7,401
edited 2005-04-19 10:58 in General Discussion
Dear Javelin users:

Today we have released the Javelin Direct Source code. It is provided·without support from Parallax and under the GNU Public License. We are considering creating a project for it on Sourceforge, so multiple people could contribute to new revisions. With this source code it is possible to develop a programming interface for other platforms (Mac, Linux, etc.). Users of the source should feel free to post changes or improvements to this program to this Javelin Stamp Discussion Forum.

You will find the download on this Parallax web page:

http://www.parallax.com/javelin/downloads.asp

Best of luck!

Ken Gracey
Parallax, Inc.

Comments

  • Ryan C. PayneRyan C. Payne Posts: 38
    edited 2005-01-19 18:50
    Ken,

    ·· That's a great thing that you guys have released the code for it. As I had written in another post yesterday, I have been contemplating writing an Eclipse Plugin for Javelin development. The Plugin will utilize the Jikes compiler to compile the Java and then would shell out to Javelin Direct to upload it. The only issue was that the plugin would only really be useful on a Win32 machine because of Javelin Direct. But since the source is now available for Javelin Direct, others could use the plugin on any platform with Eclipse and then port the communication program for that platform as well.

    ··· I guess my big question is how many Javelin users are previous Java developers that have used Eclipse in the past and would want/use this plugin if I were to sit down and write it?

    ··· Ryan
  • amandyamandy Posts: 4
    edited 2005-01-31 05:27
    Ryan,

    I would love to develop for the javelin with eclipse. You get my vote if your building a plugin. I took a stab at getting it working awhile back when I read someone had javelin direct running under wine but I couldn't get it to work. I briefly considered reverse engineering the protocol but decided I have too many other projects to waste my time on. I'm surprised there aren't more responses already to your offer. You would think the kind of people that hack around with hardware would be into alternative systems and open source code. Oh well I hope you still do it.

    Adrian.
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-02-02 14:55
    This is the source to compile/link and download a class file to the

    javelin, right?

    When I hit link in the JIDE on the program holding the main method,

    it appears only that program gets compiled (not imported classes).

    What I want is to have a command to compile/link the main program

    that includes·all imported classes into a single class file.

    This single class file I would like to email together with a download command

    to a customer so they can download new code into the javelin, without

    requiring access to classpath sources.

    Better still when compiling into a single .EXE file.

    Can someone that has read into the sources, provide these two

    commands (compile and download)· from the sources?

    Or point out how to extract the functions required to make

    these commands?



    regards peter
  • Chris WChris W Posts: 4
    edited 2005-02-04 05:15
    Within JIDE, when you choose Link from the menu JIDE first compiles the code. It will recompile any required classes which have been modified since they were last compiled. This part is done automatically by the Jikes compiler. The next step is to link the multiple .class files together into the binary that is downloaded to the Javelin Stamp. This part is quite complicated and it is what takes most of the source code in the JavelinDirect package. The final step is to communicate with the Javelin and download the linked binary.

    If you want to be able to have someone else download compiled Javelin code, then I think the best approach is for you to compile and link the code into the single binary, then you can send the binary to your customer and along with a downloader program. They can use the downloader to program a Javelin. Once nice side-effect of this approach is that the end-user can't realistically decompile the code, so they never see the source, and they can't make any changes (and so mess with the reliability).

    These are feasible modifications, assuming you are comfortable with C++ coding. I would recommend looking at the TSXCom class where it programs the Javelin. This is where JavelinDirect could be split into two versions, one which links and then saves to disk the binary file, and one that loads the binary file and programs the Javelin.

    Regards,

    Chris.
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-02-04 07:37
    Chris,

    Thanks. I found all the download is done in a single function.

    I adapted that function to save the jemData array (which is what gets

    downloaded) into a file c:\javelin.jem

    I simply download the program into a javelin so not to interfere with

    any timing. Will this work in cpp?



    regards peter
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-02-04 07:53
    Apparently, the atachement manager won't start at my pc.
    So here is the adapted download function.

    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;
    · //following block added by P. Verkaik
    · //just download program to javelin (do not interfere with timing)
    · //and as side effect the jemData array is saved as javelin.jem
    · //start of jemfile save
    · FILE *fp = fopen("c:\\javelin.jem","wb");
    · if (fp) {
    ··· for (int i=0; i<length; i++) {
    ····· fputc(jemData[noparse][[/noparse]i],fp);
    ··· }
    ··· fclose(fp);
    · }
    · //end of jemfile save
    · 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");
    }

    regards peter
    ·
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-02-04 08:06
    And this would be its read counterpart (for customer download)

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

    · //following block added by P. Verkaik
    · //just download jemfile to javelin (do not interfere with timing)
    · //start of jemfile read
    · FILE *fp = fopen("c:\\javelin.jem","rb");
    · if (fp) {
    ··· fseek(fp,0,SEEK_END);
    ··· length = ftell(fp);

    ····fseek(fp,0,SEEK_START);
    ··· jemData = (char *)malloc(length);
    ··· for (int i=0; i<length; i++) {
    ····· jemData[noparse][[/noparse]i] = fgetc(fp);
    ··· }
    ··· fclose(fp);
    · }
    · //end of jemfile read

    · 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");

    }

    regards peter
  • Chris WChris W Posts: 4
    edited 2005-02-04 16:21
    You've got the right idea. One change I would suggest: when reading back the binary, malloc an extra 18 bytes or so. Notice the TODO: comment further down. The code reads past the end of the array and this could cause a segmentation fault if the array is not big enough.

    Regards,

    Chris.
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-02-04 17:11
    Chris,

    I was reading into main() and found that ifndef WIN32, then the jemfile

    gets saved. I guess I can duplicate that code into the WIN32· section

    so it always gets saved. Also, I prefer adding a --jem option to download

    an existing jemfile rather than compile/link sources. That would leave

    a single downloader program and the new feature is run from main().

    Wouldn't that be better than adjusting the download routine?



    regards peter
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-02-04 18:41
    Chris,
    I adapted the main.cpp and posted it here
    http://groups.yahoo.com/group/JavelinCode/files/JavelinDirect_v0.1.0/

    Could you check this for me. I think it is ok.
    It now generates a jemfile if you don't specify --jem
    If you do specify --jem it merely downloads the jemfile.

    regards peter
    ·
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-02-21 12:13
    Is someone able and willing to compile the source,

    with my adapted main, for the windows platform?

    You require Borland C++ builder 6 to do so.

    Thank you.



    regards peter
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-04-13 14:25
    I installed Borland C++ 6 enterprise trial and tried to compile the sources.

    Compiling seems to be ok (though 36 warnings), but I get 29 linker errors, all related

    to·unresolved externals __fastcall referenced from cdiroutl.cpp

    like:

    [noparse][[/noparse]Linker Error] Unresolved external '__fastcall Outline::TCustomOutline::~TCustomOutline()' referenced from C:\PROGRAM FILES\BORLAND\CBUILDER6\LIB\BCBSMP.LIB|.\cdiroutl.cpp

    These·__fastcall appear only in TSXComm but that compiles ok.
    Can someone tell me how to resolve these·externals?

    regards peter
    ·
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-04-13 20:29
    I succeeded in compiling the sources.

    The new sources (v1.1) are located here:

    http://groups.yahoo.com/group/JavelinCode/files/JavelinDirect_v.1.1/

    A sample project that utilizes v1.1 is located here:

    http://groups.yahoo.com/group/JavelinCode/files/Javelin%20Stamp%20IDE/Projects/SampleProject/



    Now you can send a zip file to a customer. He only needs to unzip it

    and run a batchfile (works even within Explorer), and he does not need

    the source files.



    regards peter
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-04-19 10:58
    I updated the JavelinDirect to version 1.2

    The v1.1 option --jem is replaced by two options: --link and --load

    --link only creates the jem file (the javelin does not need to be·connected)

    --load only downloads the jem file to the javelin (this is the v1.1 --jem option)

    How to use this to let customers download new programs themselves:
    http://groups.yahoo.com/group/JavelinCode/files/Javelin%20Stamp%20IDE/Projects/SampleProject/

    The v1.2 sources:
    http://groups.yahoo.com/group/JavelinCode/files/JavelinDirect/

    regards peter
    ·
Sign In or Register to comment.