Schluss fuer heute

This commit is contained in:
Tristan Krause 2019-03-28 16:04:38 +01:00
parent 0d439d97b8
commit 2a8e3061db
6 changed files with 45 additions and 46 deletions

View file

@ -151,7 +151,7 @@ std::vector<std::string> B15F::getBoardInfo(void)
} }
} }
bool B15F::digitaleAusgabe0(uint8_t port) bool B15F::digitalWrite0(uint8_t port)
{ {
try try
{ {
@ -164,11 +164,11 @@ bool B15F::digitaleAusgabe0(uint8_t port)
catch(DriverException& de) catch(DriverException& de)
{ {
reconnect(); reconnect();
return digitaleAusgabe0(port); return digitalWrite0(port);
} }
} }
bool B15F::digitaleAusgabe1(uint8_t port) bool B15F::digitalWrite1(uint8_t port)
{ {
try try
{ {
@ -181,11 +181,11 @@ bool B15F::digitaleAusgabe1(uint8_t port)
catch(DriverException& de) catch(DriverException& de)
{ {
reconnect(); reconnect();
return digitaleAusgabe1(port); return digitalWrite1(port);
} }
} }
uint8_t B15F::digitaleEingabe0() uint8_t B15F::digitalRead0()
{ {
try try
{ {
@ -195,11 +195,11 @@ uint8_t B15F::digitaleEingabe0()
catch(DriverException& de) catch(DriverException& de)
{ {
reconnect(); reconnect();
return digitaleEingabe0(); return digitalRead0();
} }
} }
uint8_t B15F::digitaleEingabe1() uint8_t B15F::digitalRead1()
{ {
try try
{ {
@ -209,11 +209,11 @@ uint8_t B15F::digitaleEingabe1()
catch(DriverException& de) catch(DriverException& de)
{ {
reconnect(); reconnect();
return digitaleEingabe1(); return digitalRead1();
} }
} }
bool B15F::analogeAusgabe0(uint16_t value) bool B15F::analogWrite0(uint16_t value)
{ {
try try
{ {
@ -226,11 +226,11 @@ bool B15F::analogeAusgabe0(uint16_t value)
catch(DriverException& de) catch(DriverException& de)
{ {
reconnect(); reconnect();
return analogeAusgabe0(value); return analogWrite0(value);
} }
} }
bool B15F::analogeAusgabe1(uint16_t value) bool B15F::analogWrite1(uint16_t value)
{ {
try try
{ {
@ -243,11 +243,11 @@ bool B15F::analogeAusgabe1(uint16_t value)
catch(DriverException& de) catch(DriverException& de)
{ {
reconnect(); reconnect();
return analogeAusgabe1(value); return analogWrite1(value);
} }
} }
uint16_t B15F::analogeEingabe(uint8_t channel) uint16_t B15F::analogRead(uint8_t channel)
{ {
try try
{ {
@ -258,13 +258,14 @@ uint16_t B15F::analogeEingabe(uint8_t channel)
catch(DriverException& de) catch(DriverException& de)
{ {
reconnect(); reconnect();
return analogeEingabe(channel); return analogRead(channel);
} }
} }
bool B15F::analogEingabeSequenz(uint8_t channel_a, uint16_t* buffer_a, uint32_t offset_a, uint8_t channel_b, uint16_t* buffer_b, uint32_t offset_b, uint16_t start, int16_t delta, uint16_t count) bool B15F::analogEingabeSequenz(uint8_t channel_a, uint16_t* buffer_a, uint32_t offset_a, uint8_t channel_b, uint16_t* buffer_b, uint32_t offset_b, uint16_t start, int16_t delta, uint16_t count)
{ {
discard();
try try
{ {
@ -278,23 +279,21 @@ bool B15F::analogEingabeSequenz(uint8_t channel_a, uint16_t* buffer_a, uint32_t
if(aw != MSG_OK) if(aw != MSG_OK)
{ {
throw std::runtime_error("Out of sync"); std::cout << PRE << "Out of sync" << std::endl;
//discard(); return analogEingabeSequenz(channel_a, buffer_a, offset_a, channel_b, buffer_b, offset_b, start, delta, count);
//return analogEingabeSequenz(channel_a, buffer_a, offset_a, channel_b, buffer_b, offset_b, start, delta, count);
} }
uint8_t block[4];
for(uint16_t i = 0; i < count; i++) for(uint16_t i = 0; i < count; i++)
{ {
uint8_t block[4]; bool crc_ok = readBlock(&block[0], 0);
bool crc_ok = true;
do if (!crc_ok)
{ {
crc_ok = readBlock(&block[0], 0); std::cout << PRE << "bad crc" << std::endl;
if(!crc_ok) return analogEingabeSequenz(channel_a, buffer_a, offset_a, channel_b, buffer_b, offset_b, start, delta, count);
std::cout << "fordere neu an" << std::endl;
} }
while(!crc_ok);
std::cout << "OK" << std::endl;
buffer_a[offset_a + i] = ((uint16_t) block[0]) | (((uint16_t) block[1]) << 8); buffer_a[offset_a + i] = ((uint16_t) block[0]) | (((uint16_t) block[1]) << 8);
buffer_b[offset_b + i] = ((uint16_t) block[2]) | (((uint16_t) block[3]) << 8); buffer_b[offset_b + i] = ((uint16_t) block[2]) | (((uint16_t) block[3]) << 8);
@ -305,7 +304,6 @@ bool B15F::analogEingabeSequenz(uint8_t channel_a, uint16_t* buffer_a, uint32_t
return aw; return aw;
std::cout << PRE << "Da ging etwas verloren" << std::endl; std::cout << PRE << "Da ging etwas verloren" << std::endl;
discard();
return analogEingabeSequenz(channel_a, buffer_a, offset_a, channel_b, buffer_b, offset_b, start, delta, count); return analogEingabeSequenz(channel_a, buffer_a, offset_a, channel_b, buffer_b, offset_b, start, delta, count);
} }
catch(DriverException& de) catch(DriverException& de)
@ -399,14 +397,7 @@ bool B15F::readBlock(uint8_t* buffer, uint16_t offset)
while(len--) while(len--)
{ {
int code = read(usart, buffer, 1); *buffer = readByte();
if(code != 1)
{
std::cout << PRE << "read code: " << code << std::endl;
tcflush(usart, TCIFLUSH); // leere Eingangspuffer
writeByte(MSG_FAIL);
return false;
}
crc ^= *buffer++; crc ^= *buffer++;
for (uint8_t i = 0; i < 8; i++) for (uint8_t i = 0; i < 8; i++)

View file

@ -30,13 +30,13 @@ public:
std::vector<std::string> getBoardInfo(void); std::vector<std::string> getBoardInfo(void);
// Board Befehle // Board Befehle
bool digitaleAusgabe0(uint8_t); bool digitalWrite0(uint8_t);
bool digitaleAusgabe1(uint8_t); bool digitalWrite1(uint8_t);
uint8_t digitaleEingabe0(void); uint8_t digitalRead0(void);
uint8_t digitaleEingabe1(void); uint8_t digitalRead1(void);
bool analogeAusgabe0(uint16_t); bool analogWrite0(uint16_t);
bool analogeAusgabe1(uint16_t); bool analogWrite1(uint16_t);
uint16_t analogeEingabe(uint8_t); uint16_t analogRead(uint8_t);
bool analogEingabeSequenz(uint8_t channel_a, uint16_t* buffer_a, uint32_t offset_a, uint8_t channel_b, uint16_t* buffer_b, uint32_t offset_b, uint16_t start, int16_t delta, uint16_t count); bool analogEingabeSequenz(uint8_t channel_a, uint16_t* buffer_a, uint32_t offset_a, uint8_t channel_b, uint16_t* buffer_b, uint32_t offset_b, uint16_t start, int16_t delta, uint16_t count);
// Serielle Verbindung // Serielle Verbindung
@ -53,7 +53,7 @@ public:
private: private:
int usart = -1; int usart = -1;
uint16_t timeout = 200; // ms uint16_t timeout = 32; // ms
uint16_t block_timeout = 1; // ms uint16_t block_timeout = 1; // ms
int TEST = 0; int TEST = 0;

Binary file not shown.

BIN
main

Binary file not shown.

View file

@ -32,7 +32,7 @@ void kennlinieErsterQuadrant()
uint8_t curve = 0; uint8_t curve = 0;
for(uint16_t u_gs = u_gs_start; u_gs <= u_gs_end; u_gs += u_gs_delta) for(uint16_t u_gs = u_gs_start; u_gs <= u_gs_end; u_gs += u_gs_delta)
{ {
drv.analogeAusgabe1(u_gs); drv.analogWrite1(u_gs);
drv.analogEingabeSequenz(0, &ba[0], 0, 1, &bb[0], 0, 0, delta, sample_count); drv.analogEingabeSequenz(0, &ba[0], 0, 1, &bb[0], 0, 0, delta, sample_count);
drv.delay(10); drv.delay(10);
@ -79,7 +79,7 @@ void kennlinieZweiterQuadrant()
uint8_t curve = 0; uint8_t curve = 0;
for(uint16_t u_gs = u_gs_start; u_gs <= u_gs_end; u_gs += u_gs_delta) for(uint16_t u_gs = u_gs_start; u_gs <= u_gs_end; u_gs += u_gs_delta)
{ {
drv.analogeAusgabe1(u_gs); drv.analogWrite1(u_gs);
drv.analogEingabeSequenz(0, &ba[0], 0, 1, &bb[0], 0, 0, delta, sample_count); drv.analogEingabeSequenz(0, &ba[0], 0, 1, &bb[0], 0, 0, delta, sample_count);
@ -102,7 +102,15 @@ int main()
B15F& drv = B15F::getInstance(); B15F& drv = B15F::getInstance();
drv.init(); drv.init();
kennlinieZweiterQuadrant(); int n = 0;
while(1)
{
uint16_t ba[1024];
uint16_t bb[1024];
drv.analogEingabeSequenz(0, &ba[0], 0, 1, &bb[0], 0, 0, 1, 1023);
std::cout << n++ << std::endl;
}
// speichern und plotty starten // speichern und plotty starten
pf.writeToFile("test_plot"); pf.writeToFile("test_plot");

BIN
main.o

Binary file not shown.