use high speed as default, fix current checksum

This commit is contained in:
John-Michael Baier
2020-12-20 17:09:38 +01:00
parent e95466f148
commit 6b1a243d3a
2 changed files with 8 additions and 8 deletions
+3 -3
View File
@@ -26,7 +26,7 @@ A tool for loading firmware to the eBUS adapter PIC.
-m, --mask=MASK set IP mask (e.g. 24)
-M, --macip set the MAC address suffix from the IP address
-r, --reset reset the device at the end on success
-s, --speed enable high speed transfer
-s, --slow use low speed for transfer
-v, --verbose enable verbose output
-?, --help give this help list
--usage give a short usage message
@@ -49,7 +49,7 @@ Firmware version not found
MAC address: ae:b0:53:26:15:80
IP address: DHCP
New firmware version: 1 [d5d7]
New firmware version: 1 [c5e7]
erasing flash: done.
flashing:
@@ -72,7 +72,7 @@ On success, the output looks like this:
Device ID: 30b0 (PIC16F15356)
Device revision: 0.1
Bootloader version: 1 [0a6c]
Firmware version: 1 [d5d7]
Firmware version: 1 [c5e7]
MAC address: ae:b0:53:26:15:80
IP address: DHCP
+5 -5
View File
@@ -34,7 +34,7 @@ static const struct argp_option argpoptions[] = {
{"macip", 'M', nullptr, 0, "set the MAC address suffix from the IP address", 0 },
{"flash", 'f', "FILE", 0, "flash the FILE to the device", 0 },
{"reset", 'r', nullptr, 0, "reset the device at the end on success", 0 },
{"speed", 's', nullptr, 0, "enable high speed transfer", 0 },
{"slow", 's', nullptr, 0, "use low speed for transfer", 0 },
{nullptr, 0, nullptr, 0, nullptr, 0 },
};
@@ -47,7 +47,7 @@ static bool setMask = false;
static uint8_t setMaskLen = 0x1f;
static char* flashFile = nullptr;
static bool reset = false;
static bool highSpeed = false;
static bool lowSpeed = false;
bool parseByte(const char *arg, uint8_t minValue, uint8_t maxValue, uint8_t *result) {
char* strEnd = nullptr;
@@ -149,7 +149,7 @@ error_t parse_opt(int key, char *arg, struct argp_state *state) {
reset = true;
break;
case 's':
highSpeed = true;
lowSpeed = true;
break;
default:
return ARGP_ERR_UNKNOWN;
@@ -209,7 +209,7 @@ typedef union
#define FRAME_HEADER_LEN 9
#define FRAME_MAX_LEN (FRAME_HEADER_LEN+2*WRITE_FLASH_BLOCKSIZE)
#define BAUDRATE_NORMAL B115200
#define BAUDRATE_LOW B115200
#define BAUDRATE_HIGH B921600
#define WAIT_BYTE_TRANSFERRED_MILLIS 200
#define WAIT_BITRATE_DETECTION_MICROS 100
@@ -594,7 +594,7 @@ int openSerial(std::string port) {
struct termios termios;
memset(&termios, 0, sizeof(termios));
if (cfsetspeed(&termios, highSpeed ? BAUDRATE_HIGH : BAUDRATE_NORMAL)!=0) {
if (cfsetspeed(&termios, lowSpeed ? BAUDRATE_LOW : BAUDRATE_HIGH)!=0) {
std::cerr<<"unable to set speed "<<std::endl;
close(fd);
return -1;