1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#include "rsp.h"
#include "rsp_lemm.h"
#include "utils.h"
#include <string.h> /* memset() */
#include <stdio.h> /* 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;
}
|