renamed read_timeout & write_timeout
This commit is contained in:
parent
2e88b9c980
commit
8d00bb0600
231 changed files with 5160 additions and 13377 deletions
|
@ -229,7 +229,7 @@ uint16_t B15F::analogRead(uint8_t channel)
|
|||
channel
|
||||
};
|
||||
|
||||
int n_sent = usart.write_timeout(&rq[0], 0, sizeof(rq), 1000);
|
||||
int n_sent = usart.receive(&rq[0], 0, sizeof(rq), 1000);
|
||||
if(n_sent != sizeof(rq))
|
||||
abort("Sent failed");
|
||||
|
||||
|
@ -302,7 +302,7 @@ uint8_t B15F::pwmSetFrequency(uint32_t freq)
|
|||
static_cast<uint8_t>((freq >> 24) & 0xFF)
|
||||
};
|
||||
|
||||
int n_sent = usart.write_timeout(&rq[0], 0, sizeof(rq), 1000);
|
||||
int n_sent = usart.receive(&rq[0], 0, sizeof(rq), 1000);
|
||||
if(n_sent != sizeof(rq))
|
||||
abort("Sent failed");
|
||||
|
||||
|
@ -321,7 +321,7 @@ bool B15F::pwmSetValue(uint8_t value)
|
|||
value
|
||||
};
|
||||
|
||||
int n_sent = usart.write_timeout(&rq[0], 0, sizeof(rq), 1000);
|
||||
int n_sent = usart.receive(&rq[0], 0, sizeof(rq), 1000);
|
||||
if(n_sent != sizeof(rq))
|
||||
abort("Sent failed");
|
||||
|
||||
|
@ -341,7 +341,7 @@ bool B15F::setRegister(uint8_t adr, uint8_t val)
|
|||
val
|
||||
};
|
||||
|
||||
int n_sent = usart.write_timeout(&rq[0], 0, sizeof(rq), 1000);
|
||||
int n_sent = usart.receive(&rq[0], 0, sizeof(rq), 1000);
|
||||
if(n_sent != sizeof(rq))
|
||||
abort("Sent failed");
|
||||
|
||||
|
@ -360,7 +360,7 @@ uint8_t B15F::getRegister(uint8_t adr)
|
|||
adr
|
||||
};
|
||||
|
||||
int n_sent = usart.write_timeout(&rq[0], 0, sizeof(rq), 1000);
|
||||
int n_sent = usart.receive(&rq[0], 0, sizeof(rq), 1000);
|
||||
if(n_sent != sizeof(rq))
|
||||
abort("Sent failed");
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ void USART::writeU32(uint32_t w)
|
|||
throw USARTException("Fehler beim Senden: writeU32()");
|
||||
}
|
||||
|
||||
int USART::read_timeout(uint8_t* buffer, uint16_t offset, uint8_t len, uint32_t timeout)
|
||||
int USART::transmit(uint8_t *buffer, uint16_t offset, uint8_t len, uint32_t timeout)
|
||||
{
|
||||
uint32_t elapsed = 0;
|
||||
int n_read = -1;
|
||||
|
@ -111,7 +111,7 @@ int USART::read_timeout(uint8_t* buffer, uint16_t offset, uint8_t len, uint32_t
|
|||
return 0;
|
||||
}
|
||||
|
||||
int USART::write_timeout(uint8_t* buffer, uint16_t offset, uint8_t len, uint32_t timeout)
|
||||
int USART::receive(uint8_t *buffer, uint16_t offset, uint8_t len, uint32_t timeout)
|
||||
{
|
||||
uint32_t elapsed = 0;
|
||||
int n_sent = -1;
|
||||
|
@ -165,13 +165,13 @@ void USART::writeBlock(uint8_t* buffer, uint16_t offset, uint8_t len)
|
|||
// send block
|
||||
clearOutputBuffer();
|
||||
clearInputBuffer();
|
||||
int n_sent = write_timeout(&block_buffer[0], 0, len + 3, us_per_bit * n_total);
|
||||
int n_sent = receive(&block_buffer[0], 0, len + 3, us_per_bit * n_total);
|
||||
if(n_sent != n_total)
|
||||
throw std::runtime_error("fatal (send): " + std::to_string(n_sent));
|
||||
|
||||
/*for(uint8_t i = 0; i < len + 3; i++)
|
||||
{
|
||||
write_timeout(&block_buffer[i], 0, 1, us_per_bit * n_total);
|
||||
receive(&block_buffer[i], 0, 1, us_per_bit * n_total);
|
||||
//tcdrain(file_desc);
|
||||
//usleep(1000);
|
||||
}*/
|
||||
|
@ -182,7 +182,7 @@ void USART::writeBlock(uint8_t* buffer, uint16_t offset, uint8_t len)
|
|||
//usleep(us_per_bit * n_total * 10);
|
||||
|
||||
// check response
|
||||
int n_read = read_timeout(&aw, 0, 1, us_per_bit * n_blocks_total * 10);
|
||||
int n_read = transmit(&aw, 0, 1, us_per_bit * n_blocks_total * 10);
|
||||
for(uint16_t i = 0; i < 255 && n_read != 1; i++)
|
||||
{
|
||||
writeByte(0x80); // Stoppzeichen für Block
|
||||
|
@ -192,7 +192,7 @@ void USART::writeBlock(uint8_t* buffer, uint16_t offset, uint8_t len)
|
|||
}
|
||||
std::cout << "WARNING: read error (" << n_read << "), retry #" << (int) i << std::endl;
|
||||
usleep(us_per_bit*100);
|
||||
n_read = read_timeout(&aw, 0, 1, us_per_bit);
|
||||
n_read = transmit(&aw, 0, 1, us_per_bit);
|
||||
}
|
||||
|
||||
if(n_read != 1)
|
||||
|
|
|
@ -100,8 +100,9 @@ public:
|
|||
*/
|
||||
uint16_t readInt(void);
|
||||
|
||||
int read_timeout(uint8_t* buffer, uint16_t offset, uint8_t len, uint32_t timeout);
|
||||
int write_timeout(uint8_t* buffer, uint16_t offset, uint8_t len, uint32_t timeout);
|
||||
int transmit(uint8_t *buffer, uint16_t offset, uint8_t len, uint32_t timeout);
|
||||
int receive(uint8_t *buffer, uint16_t offset, uint8_t len, uint32_t timeout);
|
||||
|
||||
void writeBlock(uint8_t* buffer, uint16_t offset, uint8_t len);
|
||||
bool readBlock(uint8_t* buffer, uint16_t offset);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue