bugsuche+
This commit is contained in:
parent
e0a4be7685
commit
bb5d16ca88
BIN
driver/cli
BIN
driver/cli
Binary file not shown.
|
@ -1,7 +1,6 @@
|
|||
/** TODO
|
||||
*
|
||||
* - throw exception -> raise SIGINT
|
||||
* - delete view stack
|
||||
*/
|
||||
|
||||
|
||||
|
@ -81,7 +80,7 @@ void init()
|
|||
// init b15 driver
|
||||
B15F::getInstance();
|
||||
std::cout << std::endl << "Starte in 3s ..." << std::endl;
|
||||
//sleep(3);
|
||||
sleep(3);
|
||||
|
||||
// init all ncurses stuff
|
||||
initscr();
|
||||
|
@ -262,7 +261,7 @@ void show_digital_output0(int)
|
|||
{
|
||||
ViewPromt* view = new ViewPromt();
|
||||
view->setTitle("Digitale Ausgabe BE0");
|
||||
view->setMessage("\nEingabe Port-Wert (hex): 0x");
|
||||
view->setMessage("\nAusgabe Port-Wert (hex): 0x");
|
||||
view->setCancel("[ Zurueck ]", true);
|
||||
view->setConfirm("[ OK ]", &write_digital_output0);
|
||||
view->repaint();
|
||||
|
@ -275,7 +274,7 @@ void show_digital_output1(int)
|
|||
{
|
||||
ViewPromt* view = new ViewPromt();
|
||||
view->setTitle("Digitale Ausgabe BE1");
|
||||
view->setMessage("\nEingabe Port-Wert (hex): 0x");
|
||||
view->setMessage("\nAusgabe Port-Wert (hex): 0x");
|
||||
view->setCancel("[ Zurueck ]", true);
|
||||
view->setConfirm("[ OK ]", &write_digital_output1);
|
||||
view->repaint();
|
||||
|
@ -288,7 +287,7 @@ void show_analog_output0(int)
|
|||
{
|
||||
ViewPromt* view = new ViewPromt();
|
||||
view->setTitle("Analoge Ausgabe AA0");
|
||||
view->setMessage("\nEingabe 10-Bit-Wert (0...1023): ");
|
||||
view->setMessage("\nAusgabe 10-Bit-Wert (0...1023): ");
|
||||
view->setCancel("[ Zurueck ]", true);
|
||||
view->setConfirm("[ OK ]", &write_analog_output0);
|
||||
view->repaint();
|
||||
|
@ -301,7 +300,7 @@ void show_analog_output1(int)
|
|||
{
|
||||
ViewPromt* view = new ViewPromt();
|
||||
view->setTitle("Analoge Ausgabe AA1");
|
||||
view->setMessage("\nEingabe 10-Bit-Wert (0...1023): ");
|
||||
view->setMessage("\nAusgabe 10-Bit-Wert (0...1023): ");
|
||||
view->setCancel("[ Zurueck ]", true);
|
||||
view->setConfirm("[ OK ]", &write_analog_output1);
|
||||
view->repaint();
|
||||
|
|
|
@ -56,17 +56,14 @@ void B15F::init()
|
|||
void B15F::reconnect()
|
||||
{
|
||||
uint8_t tries = RECONNECT_TRIES;
|
||||
while(tries--)
|
||||
while(tries-- && false)
|
||||
{
|
||||
delay_ms(RECONNECT_TIMEOUT);
|
||||
|
||||
discard();
|
||||
|
||||
if(testConnection())
|
||||
{
|
||||
std::cout << "OK" << std::endl << std::flush;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -76,10 +73,10 @@ void B15F::reconnect()
|
|||
void B15F::discard(void)
|
||||
{
|
||||
usart.clearOutputBuffer();
|
||||
for(uint8_t i = 0; i < 8; i++)
|
||||
for(uint8_t i = 0; i < 16; i++)
|
||||
{
|
||||
usart.writeByte(RQ_DISC); // sende discard Befehl (verwerfe input)
|
||||
delay_ms((16000 / BAUDRATE) + 1); // warte mindestens eine Millisekunde, gegebenenfalls mehr
|
||||
delay_ms(4);
|
||||
}
|
||||
usart.clearInputBuffer();
|
||||
}
|
||||
|
@ -140,7 +137,6 @@ std::vector<std::string> B15F::getBoardInfo(void)
|
|||
|
||||
bool B15F::activateSelfTestMode()
|
||||
{
|
||||
//usart.clearInputBuffer();
|
||||
usart.writeByte(RQ_ST);
|
||||
|
||||
uint8_t aw = usart.readByte();
|
||||
|
@ -149,86 +145,82 @@ bool B15F::activateSelfTestMode()
|
|||
|
||||
bool B15F::digitalWrite0(uint8_t port)
|
||||
{
|
||||
//usart.clearInputBuffer();
|
||||
usart.writeByte(RQ_BA0);
|
||||
usart.writeByte(port);
|
||||
|
||||
uint8_t aw = usart.readByte();
|
||||
delay_us(1);
|
||||
delay_us(10);
|
||||
return aw == MSG_OK;
|
||||
}
|
||||
|
||||
bool B15F::digitalWrite1(uint8_t port)
|
||||
{
|
||||
//usart.clearInputBuffer();
|
||||
usart.writeByte(RQ_BA1);
|
||||
usart.writeByte(port);
|
||||
|
||||
uint8_t aw = usart.readByte();
|
||||
delay_us(1);
|
||||
delay_us(10);
|
||||
return aw == MSG_OK;
|
||||
}
|
||||
|
||||
uint8_t B15F::digitalRead0()
|
||||
{
|
||||
//usart.clearInputBuffer();
|
||||
usart.clearInputBuffer();
|
||||
usart.writeByte(RQ_BE0);
|
||||
uint8_t byte = usart.readByte();
|
||||
delay_us(1);
|
||||
delay_us(10);
|
||||
return byte;
|
||||
}
|
||||
|
||||
uint8_t B15F::digitalRead1()
|
||||
{
|
||||
//usart.clearInputBuffer();
|
||||
usart.clearInputBuffer();
|
||||
usart.writeByte(RQ_BE1);
|
||||
uint8_t byte = usart.readByte();
|
||||
delay_us(1);
|
||||
delay_us(10);
|
||||
return byte;
|
||||
}
|
||||
|
||||
uint8_t B15F::readDipSwitch()
|
||||
{
|
||||
//usart.clearInputBuffer();
|
||||
usart.clearInputBuffer();
|
||||
usart.writeByte(RQ_DSW);
|
||||
uint8_t byte = usart.readByte();
|
||||
delay_us(1);
|
||||
delay_us(10);
|
||||
return byte;
|
||||
}
|
||||
|
||||
bool B15F::analogWrite0(uint16_t value)
|
||||
{
|
||||
//usart.clearInputBuffer();
|
||||
usart.writeByte(RQ_AA0);
|
||||
usart.writeInt(value);
|
||||
|
||||
uint8_t aw = usart.readByte();
|
||||
delay_us(1);
|
||||
delay_us(10);
|
||||
return aw == MSG_OK;
|
||||
}
|
||||
|
||||
bool B15F::analogWrite1(uint16_t value)
|
||||
{
|
||||
//usart.clearInputBuffer();
|
||||
usart.writeByte(RQ_AA1);
|
||||
usart.writeInt(value);
|
||||
|
||||
uint8_t aw = usart.readByte();
|
||||
delay_us(1);
|
||||
delay_us(10);
|
||||
return aw == MSG_OK;
|
||||
}
|
||||
|
||||
uint16_t B15F::analogRead(uint8_t channel)
|
||||
{
|
||||
usart.clearInputBuffer();
|
||||
if(channel > 7)
|
||||
throw DriverException("Bad ADC channel: " + std::to_string(channel));
|
||||
//usart.clearInputBuffer();
|
||||
usart.writeByte(RQ_ADC);
|
||||
usart.writeByte(channel);
|
||||
uint16_t adc = usart.readInt();
|
||||
if(adc > 1023)
|
||||
throw DriverException("Bad ADC data detected");
|
||||
delay_us(1);
|
||||
delay_us(50);
|
||||
return adc;
|
||||
}
|
||||
|
||||
|
@ -258,7 +250,7 @@ void B15F::analogSequence(uint8_t channel_a, uint16_t* buffer_a, uint32_t offset
|
|||
if(aw != MSG_OK)
|
||||
throw DriverException("Sequenz unterbrochen");
|
||||
|
||||
delay_us(1);
|
||||
delay_us(10);
|
||||
}
|
||||
|
||||
void B15F::delay_ms(uint16_t ms)
|
||||
|
|
|
@ -132,7 +132,7 @@ private:
|
|||
int file_desc = -1; // Linux Dateideskriptor
|
||||
uint32_t baudrate = 9600;
|
||||
int TEST = 0;
|
||||
uint8_t timeout = 5; // in Dezisekunden
|
||||
uint8_t timeout = 10; // in Dezisekunden
|
||||
uint8_t block_buffer[MAX_BLOCK_SIZE + 3];
|
||||
|
||||
// debug statistics
|
||||
|
|
Loading…
Reference in a new issue