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
+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;