formatting

This commit is contained in:
john30
2021-01-10 15:36:02 +01:00
parent a1b289edac
commit 5c07889801
4 changed files with 115 additions and 104 deletions
+3 -2
View File
@@ -174,7 +174,7 @@ class Device {
* Return whether the device is currently in arbitration.
* @return true when the device is currently in arbitration.
*/
bool isArbitrating() const { return m_arbitrationMaster != SYN; };
bool isArbitrating() const { return m_arbitrationMaster != SYN; }
/**
* Return the device name.
@@ -236,7 +236,8 @@ class Device {
* @param incomplete the variable in which to store when a partial transfer needs another poll.
* @return true on success, false on error.
*/
virtual bool read(symbol_t* value, bool isAvailable, ArbitrationState* arbitrationState=nullptr, bool* incomplete=nullptr);
virtual bool read(symbol_t* value, bool isAvailable, ArbitrationState* arbitrationState = nullptr,
bool* incomplete = nullptr);
/** the device name (e.g. "/dev/ttyUSB0" for serial, "127.0.0.1:1234" for network). */
const char* m_name;
+21 -11
View File
@@ -406,7 +406,8 @@ int readVersion(int fd, bool verbose=true) {
if (verbose) {
std::cout << "Max packet size: " << static_cast<unsigned>(frame.data[2] | (frame.data[3] << 8)) << std::endl;
}
std::cout << "Device ID: " << std::setfill('0') << std::setw(4) << std::hex << static_cast<unsigned>(frame.data[6] | (frame.data[7] << 8));
std::cout << "Device ID: " << std::setfill('0') << std::setw(4) << std::hex
<< static_cast<unsigned>(frame.data[6] | (frame.data[7] << 8));
if (frame.data[6] == 0xb0 && frame.data[7] == 0x30) {
std::cout << " (PIC16F15356)";
}
@@ -414,10 +415,14 @@ int readVersion(int fd, bool verbose=true) {
if (verbose) {
std::cout << "Blocksize erase: " << std::dec << static_cast<unsigned>(frame.data[10]) << std::endl;
std::cout << "Blocksize write: " << std::dec << static_cast<unsigned>(frame.data[11]) << std::endl;
std::cout << "User ID 1: " << std::setfill('0') << std::setw(2) << std::hex << static_cast<unsigned>(frame.data[12]) << std::endl;
std::cout << "User ID 2: " << std::setfill('0') << std::setw(2) << std::hex << static_cast<unsigned>(frame.data[13]) << std::endl;
std::cout << "User ID 3: " << std::setfill('0') << std::setw(2) << std::hex << static_cast<unsigned>(frame.data[14]) << std::endl;
std::cout << "User ID 4: " << std::setfill('0') << std::setw(2) << std::hex << static_cast<unsigned>(frame.data[15]) << std::endl;
std::cout << "User ID 1: " << std::setfill('0') << std::setw(2) << std::hex
<< static_cast<unsigned>(frame.data[12]) << std::endl;
std::cout << "User ID 2: " << std::setfill('0') << std::setw(2) << std::hex
<< static_cast<unsigned>(frame.data[13]) << std::endl;
std::cout << "User ID 3: " << std::setfill('0') << std::setw(2) << std::hex
<< static_cast<unsigned>(frame.data[14]) << std::endl;
std::cout << "User ID 4: " << std::setfill('0') << std::setw(2) << std::hex
<< static_cast<unsigned>(frame.data[15]) << std::endl;
}
return 0;
}
@@ -448,9 +453,11 @@ int printFrameData(frame_t frame, bool skipHigh) {
}
int printFrame(frame_t frame) {
std::cout << "command: 0x" << std::setfill('0') << std::setw(2) << std::hex << static_cast<unsigned>(frame.command) << std::endl;
std::cout << "command: 0x" << std::setfill('0') << std::setw(2) << std::hex
<< static_cast<unsigned>(frame.command) << std::endl;
std::cout << "data_length: " << std::dec << static_cast<unsigned>(frame.data_length) << std::endl;
std::cout << "address: 0x" << std::setw(2) << std::hex << static_cast<unsigned>(frame.address_H) << std::setw(2) << std::hex << static_cast<unsigned>(frame.address_L);
std::cout << "address: 0x" << std::setw(2) << std::hex << static_cast<unsigned>(frame.address_H) << std::setw(2)
<< std::hex << static_cast<unsigned>(frame.address_L);
for (int pos = 0; pos < frame.data_length; ) {
if ((pos%16) == 0) {
std::cout << std::endl << std::setw(4) << static_cast<unsigned>(pos) << ":" << std::endl;
@@ -462,7 +469,8 @@ int printFrame(frame_t frame) {
return 0;
}
int readConfig(int fd, uint16_t address, uint16_t len, bool skipHigh=false, bool print=true, uint8_t* storeData=nullptr) {
int readConfig(int fd, uint16_t address, uint16_t len, bool skipHigh = false, bool print = true,
uint8_t* storeData = nullptr) {
frame_t frame;
memset(frame.buffer, 0, FRAME_MAX_LEN);
frame.command = READ_CONFIG;
@@ -617,7 +625,7 @@ int openSerial(std::string port) {
close(fd);
return -1;
}
termios.c_iflag |= 0;//IGNPAR;//IGNBRK|IGNPAR|IGNCR;
termios.c_iflag |= 0;
termios.c_oflag |= 0;
termios.c_cflag |= CS8 | CREAD | CLOCAL;
termios.c_lflag |= 0;
@@ -738,7 +746,8 @@ bool flashPic(int fd) {
uint8_t buf[WRITE_FLASH_BLOCKSIZE];
unsigned long nextAddr = ih.currentAddress();
if (nextAddr != END_BOOT_BYTES) {
std::cerr << "unexpected start address in file: 0x" << std::hex << std::setfill('0') << std::setw(4) << static_cast<unsigned>(nextAddr) << std::endl;
std::cerr << "unexpected start address in file: 0x" << std::hex << std::setfill('0') << std::setw(4)
<< static_cast<unsigned>(nextAddr) << std::endl;
return false;
}
unsigned long blockStart = END_BOOT_BYTES;
@@ -766,7 +775,8 @@ bool flashPic(int fd) {
}
if (!blank) {
if (blocks == 0) {
std::cout << std::endl << "0x" << std::hex << std::setfill('0') << std::setw(4) << static_cast<unsigned>(blockStart/2) << " ";
std::cout << std::endl << "0x" << std::hex << std::setfill('0') << std::setw(4)
<< static_cast<unsigned>(blockStart/2) << " ";
}
if (writeFlash(fd, blockStart/2, WRITE_FLASH_BLOCKSIZE, buf, true) != 0) {
// repeat once silently: