-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmd_read_byte.cpp
More file actions
48 lines (40 loc) · 799 Bytes
/
cmd_read_byte.cpp
File metadata and controls
48 lines (40 loc) · 799 Bytes
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
/*
* cmd_read_byte.cpp
*
* Created on: Mar 01, 2020
* Author: raltmeyer
*
* Implements a command
*
*/
#include <Arduino.h>
#include "28c_programmer.h"
//*********
//* Read one byte from address
//* RDBT:address
//* RDBT:00FF
void cmd_read_byte(char buffer[]) {
int param = 0;
char *tok;
char add_tmp[6];
//Parse command and parameters
tok = strtok(buffer, ":");
while ((tok != NULL)) {
//Address
if (param == 1) {
unsigned int address = 0, data = 0;
address = strtoul(tok, NULL, 16);
if (!checkAddress(address)) {
return;
}
sprintf(add_tmp, "%04X", address);
Serial.print(add_tmp);
Serial.print(":");
data = flashRead(address);
sprintf(add_tmp, "%02X", data);
Serial.println(add_tmp);
}
tok = strtok(NULL, ":");
param++;
}
}