new arbitration delay factor and range, corrected unit

This commit is contained in:
John
2021-11-28 16:00:43 +01:00
parent 43d12b7efa
commit 4ecdbea633
2 changed files with 10 additions and 10 deletions
+2 -2
View File
@@ -20,8 +20,8 @@ Usage
Usage: ebuspicloader [OPTION...] PORT Usage: ebuspicloader [OPTION...] PORT
A tool for loading firmware to the eBUS adapter PIC. A tool for loading firmware to the eBUS adapter PIC.
-a, --arbdel=NANOS set arbitration delay to NANOS ns (0-3500 in steps -a, --arbdel=US set arbitration delay to US microseconds (0-620 in
of 250, default 100, since firmware 20211120) steps of 10, default 200, since firmware 20211128)
-d, --dhcp set dynamic IP address via DHCP -d, --dhcp set dynamic IP address via DHCP
-f, --flash=FILE flash the FILE to the device -f, --flash=FILE flash the FILE to the device
-i, --ip=IP set fix IP address (e.g. 192.168.0.10) -i, --ip=IP set fix IP address (e.g. 192.168.0.10)
+8 -8
View File
@@ -52,8 +52,8 @@ static const struct argp_option argpoptions[] = {
{"ip", 'i', "IP", 0, "set fix IP address (e.g. 192.168.0.10)", 0 }, {"ip", 'i', "IP", 0, "set fix IP address (e.g. 192.168.0.10)", 0 },
{"mask", 'm', "MASK", 0, "set fix IP mask (e.g. 24)", 0 }, {"mask", 'm', "MASK", 0, "set fix IP mask (e.g. 24)", 0 },
{"macip", 'M', nullptr, 0, "set the MAC address suffix from the IP address", 0 }, {"macip", 'M', nullptr, 0, "set the MAC address suffix from the IP address", 0 },
{"arbdel", 'a', "NANOS", 0, "set arbitration delay to NANOS ns (0-3500 in steps of 250, default 100" {"arbdel", 'a', "US", 0, "set arbitration delay to US microseconds (0-620 in steps of 10, default 200"
", since firmware 20211120)", 0 }, ", since firmware 20211128)", 0 },
{"flash", 'f', "FILE", 0, "flash the FILE to the device", 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 }, {"reset", 'r', nullptr, 0, "reset the device at the end on success", 0 },
{"slow", 's', nullptr, 0, "use low speed for transfer", 0 }, {"slow", 's', nullptr, 0, "use low speed for transfer", 0 },
@@ -68,7 +68,7 @@ static bool setMacFromIp = false;
static bool setMask = false; static bool setMask = false;
static uint8_t setMaskLen = 0x1f; static uint8_t setMaskLen = 0x1f;
static bool setArbitrationDelay = false; static bool setArbitrationDelay = false;
static uint16_t setArbitrationDelayNanos = 0; static uint16_t setArbitrationDelayMicros = 0;
static char* flashFile = nullptr; static char* flashFile = nullptr;
static bool reset = false; static bool reset = false;
static bool lowSpeed = false; static bool lowSpeed = false;
@@ -167,7 +167,7 @@ error_t parse_opt(int key, char *arg, struct argp_state *state) {
argp_error(state, "invalid arbitration delay"); argp_error(state, "invalid arbitration delay");
return EINVAL; return EINVAL;
} }
if (!parseShort(arg, 0, 3500, &setArbitrationDelayNanos)) { if (!parseShort(arg, 0, 620, &setArbitrationDelayMicros)) {
argp_error(state, "invalid arbitration delay"); argp_error(state, "invalid arbitration delay");
return EINVAL; return EINVAL;
} }
@@ -896,10 +896,10 @@ void readSettings(int fd) {
uint16_t arbitrationDelay = configData[3]&0x0f; uint16_t arbitrationDelay = configData[3]&0x0f;
std::cout << "Arbitration delay: "; std::cout << "Arbitration delay: ";
if (arbitrationDelay==0x0f) { if (arbitrationDelay==0x0f) {
std::cout << "100 ns (default)" << std::endl; std::cout << "100 us (default)" << std::endl;
} else { } else {
arbitrationDelay *= 250; // steps of 250ns arbitrationDelay *= 10; // steps of 10us
std::cout << std::dec << static_cast<unsigned>(arbitrationDelay) << " ns" << std::endl; std::cout << std::dec << static_cast<unsigned>(arbitrationDelay) << " us" << std::endl;
} }
} }
@@ -916,7 +916,7 @@ bool writeSettings(int fd) {
} }
} }
if (setArbitrationDelay) { if (setArbitrationDelay) {
configData[3] = 0x30 | (setArbitrationDelayNanos/250); configData[3] = setArbitrationDelayMicros/10;
} }
if (writeConfig(fd, 0x0000, 8, configData) != 0) { if (writeConfig(fd, 0x0000, 8, configData) != 0) {
std::cerr << "failed" << std::endl; std::cerr << "failed" << std::endl;