mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Merge branch 'serial_reset'
Former-commit-id: 2564d827ae50ed429c071b285a38f0febd57f8b5
This commit is contained in:
commit
92bb518698
@ -4,6 +4,9 @@
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
|
||||
// Serial includes
|
||||
#include <serial/serial.h>
|
||||
|
||||
// Local Hyperion includes
|
||||
#include "LedRs232Device.h"
|
||||
|
||||
@ -56,6 +59,30 @@ int LedRs232Device::writeBytes(const unsigned size, const uint8_t * data)
|
||||
{
|
||||
_rs232Port.write(data, size);
|
||||
}
|
||||
catch (const serial::SerialException & serialExc)
|
||||
{
|
||||
// TODO[TvdZ]: Maybe we should limit the frequency of this error report somehow
|
||||
std::cerr << "Serial exception caught while writing to device: " << serialExc.what() << std::endl;
|
||||
std::cout << "Attempting to re-open the device." << std::endl;
|
||||
|
||||
// First make sure the device is properly closed
|
||||
try
|
||||
{
|
||||
_rs232Port.close();
|
||||
}
|
||||
catch (const std::exception & e) {}
|
||||
|
||||
// Attempt to open the device and write the data
|
||||
try
|
||||
{
|
||||
_rs232Port.open();
|
||||
_rs232Port.write(data, size);
|
||||
}
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
// We failed again, this not good, do nothing maybe in the next loop we have more success
|
||||
}
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
std::cerr << "Unable to write to RS232 device (" << e.what() << ")" << std::endl;
|
||||
|
Loading…
Reference in New Issue
Block a user