#include "rsp.h" #include "rsp_lemm.h" #include "utils.h" #include /* memset() */ #include /* printf() */ int main(int argc, char *argv[]) { int rv, i, end_input, end_loop; struct rsp_state rsp; char ds_si[10], command[16], input[100]; unsigned int poke_base, poke_off, poke_val; rv=rsp_lemm_init(&rsp, ds_si); if ( rv != 0 ) { printf("Error rsp_lemm_init() returns %i\n", rv); return 1; } if ( sscanf(ds_si, "%x", &poke_base) != 1 ) printf("Bug 20\n");; end_loop=0; while (!end_loop) { rsp_query(&rsp, "c"); // Continue if ( rsp.replied != 1 ) printf("Bug 03\n"); rsp_recv_full(&rsp); if ( rsp_check_and_clear(&rsp, "S05") != 0 ) printf("Bug 04\n"); snprintf(command, 15, "m%s,0x2d", ds_si); rsp_query(&rsp, command); // Read a lemming record if ( rsp_decode(&rsp) != 0x2d * 2 ) { printf("Bug 07\n"); } else { for (i=0; rsp.decoded[i]!='\0'; i++) { putchar(rsp.decoded[i]); if (i%2==1) putchar(' '); if (i%16==15) putchar(' '); } putchar('\n'); } end_input=0; do { printf("address value ? "); fflush(stdout); if ( fgets(input, 99, stdin) == NULL ) { //printf("pb fgets\n"); end_input=1; continue; } if ( sscanf(input,"%x %x", &poke_off, &poke_val) != 2 ) { //printf("pb sscanf\n"); end_input=1; continue; } if ( rsp_poke(&rsp, poke_base + poke_off, poke_val) != 0 ) { printf("Bug 21\n"); end_input=1; continue; } } while ( !end_input ); } rsp_quit(&rsp); return 0; }