[Dsctl-devel] SF.net SVN: dsctl: [136] src
Status: Alpha
Brought to you by:
roger-linux
From: <rog...@us...> - 2007-07-31 09:09:39
|
Revision: 136 http://dsctl.svn.sourceforge.net/dsctl/?rev=136&view=rev Author: roger-linux Date: 2007-07-31 02:09:33 -0700 (Tue, 31 Jul 2007) Log Message: ----------- Provides footwork for "ie. dsctl firmware BCD996T_V1_03_11.scn" $ hexedit BC_VUP.exe (to get a scenario of what I'm doing) There are four to six special commands (ie. *MDL, *PRG, *ULE, ...) used for uploading the firmware. I've commented the code in commands.c (load_firmware function). Just need to write the minor functions to make it tidy. *Note: Some commands I don't know what they do, so I'm dragging my feet in hopes of figuring out what these commands specifically do so I can write comprehendable code. Signed-off-by: Roger <ro...@es...> Acked-by: Roger <ro...@es...> Modified Paths: -------------- src/commands.c src/commands.h src/human_commands.c src/human_commands.h src/main.c src/main.h Modified: src/commands.c =================================================================== --- src/commands.c 2007-07-29 05:14:27 UTC (rev 135) +++ src/commands.c 2007-07-31 09:09:33 UTC (rev 136) @@ -2490,6 +2490,39 @@ } /*********************************************************************** +* Load Firmware +***********************************************************************/ +int load_firmware(int fd, FILE *infile) +{ + char line[500]; + + memset(line, 0, 500); + + printf("firmware_load: \n"); + + setup_port(fd, 9600); /* Units use default baud rates in firmware mode! */ + //get_fmodel(fd, model); /* "*MDL" */ + + //if (strcmp(model, "bcd996t") == 0) + //{ + // set_speed(fd, 115200); /* "*SPD int" - Increase baud rate to value*/ + // setup_port(fd, 115200); /* Set our program to the increased baud rate */ + // set_pgl(fd, 1000000000000000000); /* "*PGL int" - Clear Memory ??? */ + // set_ule(fd); /* "*ULE" - Unlock EEPROM ??? */ + // set_scb(fd, 1); /* "*SCB int" - Set Checksum Byte to int ??? */ + // set_prg(fd); /* "*PRG" - Enter program mode - expect a lot of data */ + + /* TODO: Put firmware names and checksums into DEFINES */ + while (fgets(line, MAXLINELEN, infile) != NULL) + { + // read in firmware + // When NULL, scanner unit will return "PROGRAM END" and "CHECKSUM= EC8BH + } + + return (0); +} + +/*********************************************************************** * Load BCD memory from file ***********************************************************************/ /* TODO: Break the following into sections for allowing upload of Modified: src/commands.h =================================================================== --- src/commands.h 2007-07-29 05:14:27 UTC (rev 135) +++ src/commands.h 2007-07-31 09:09:33 UTC (rev 136) @@ -188,9 +188,11 @@ int get_gps_rmc_data(int fd); /* TODO: Untested! */ int get_window_voltage(int fd); + /* Elongated Functions - Using above lower-level scanner command functions */ -int dump(int fd, FILE * outfile); -int load(int fd, FILE * infile); +int dump(int fd, FILE *outfile); +int load_firmware(int fd, FILE *infile); +int load(int fd, FILE *infile); int version(int fd); #endif /* _COMMANDS_H_ */ Modified: src/human_commands.c =================================================================== --- src/human_commands.c 2007-07-29 05:14:27 UTC (rev 135) +++ src/human_commands.c 2007-07-31 09:09:33 UTC (rev 136) @@ -70,7 +70,30 @@ } /*********************************************************************** - * key command + * Firmware command + ***********************************************************************/ +void human_do_firmware(int fd, int argc, char **args) +{ + printf("human_do_firmware: \n"); + + FILE *infile; + char errorstr[100]; + + /* Check for File & + * TODO: Check File type and version? */ + if ((infile = fopen(args[0], "r")) != NULL) + load_firmware(fd, infile); + else + { + snprintf(errorstr, 100, "load from \"%s\" failed", args[1]); + perror(errorstr); + return; + } +} + + +/*********************************************************************** + * Key command * TODO: Use switch instead of if statements? Move over key defines to here. ***********************************************************************/ void human_do_key(int fd, int argc, char **args) Modified: src/human_commands.h =================================================================== --- src/human_commands.h 2007-07-29 05:14:27 UTC (rev 135) +++ src/human_commands.h 2007-07-31 09:09:33 UTC (rev 136) @@ -73,6 +73,7 @@ #define K_MODE_RELEASE "R" /* Release and Cancel Hold Key state */ void human_do_dump(int fd, int argc, char **args); +void human_do_firmware(int fd, int argc, char **args); void human_do_key(int fd, int argc, char **args); void human_do_load(int fd, int argc, char **args); void human_do_status(int fd, int argc, char **args); Modified: src/main.c =================================================================== --- src/main.c 2007-07-29 05:14:27 UTC (rev 135) +++ src/main.c 2007-07-31 09:09:33 UTC (rev 136) @@ -294,6 +294,10 @@ case C_DUMP: human_do_dump(fd, cmd_argc, cmd_argv); break; + + case C_FIRMWARE: + human_do_firmware(fd, cmd_argc, cmd_argv); + break; case C_HELP: human_help(fd, cmd_argc, cmd_argv); @@ -334,6 +338,8 @@ if (strncmp(cmd, "du", 2) == 0) return (C_DUMP); + else if (strncmp(cmd, "f", 1) == 0) + return (C_FIRMWARE); else if (strncmp(cmd, "h", 1) == 0) return (C_HELP); else if (strncmp(cmd, "k", 1) == 0) Modified: src/main.h =================================================================== --- src/main.h 2007-07-29 05:14:27 UTC (rev 135) +++ src/main.h 2007-07-31 09:09:33 UTC (rev 136) @@ -46,8 +46,9 @@ #define C_DATA 11 #define C_VERSION 12 #define C_DUMP 13 -#define C_LOAD 14 -#define C_KEY 15 +#define C_FIRMWARE 14 +#define C_LOAD 15 +#define C_KEY 16 /*********************************************************************** * prototypes This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |