faster startup

This commit is contained in:
Tristan Krause 2019-03-27 12:57:51 +01:00
parent 3473057f98
commit 46809d811b
8 changed files with 48 additions and 15 deletions

View file

@ -19,6 +19,7 @@ void B15F::init()
usart = open(SERIAL_DEVICE.c_str(), O_RDWR | O_NOCTTY | O_NDELAY);
struct termios options;
tcgetattr(usart, &options);
options.c_cflag = CS8 | CLOCAL | CREAD;
options.c_iflag = IGNPAR;
options.c_oflag = 0;
options.c_lflag = 0;
@ -28,25 +29,28 @@ void B15F::init()
tcflush(usart, TCIFLUSH);
std::cout << "OK" << std::endl;
delay(1);
// Verbindungstest muss dreimal erfolgreich sein
std::cout << PRE << "Teste Verbindung... " << std::flush;
for(uint8_t i = 0; i < 3; i++)
std::cout << PRE << "Teste Verbindung... " << std::flush;
uint8_t tries = 3;
while(tries--)
{
// verwerfe Daten, die µC noch hat
discard();
if(!testConnection())
throw DriverException("Verbindungstest fehlgeschlagen. Neueste Version im Einsatz?");
}
std::cout << "OK" << std::endl;
std::cout << PRE << "Teste Integer Konvertierung... " << std::flush;
for(uint8_t i = 0; i < 3; i++)
continue;
if(!testIntConv())
throw DriverException("Konvertierung fehlgeschlagen.");
continue;
break;
}
if(tries == 0)
throw DriverException("Verbindungstest fehlgeschlagen. Neueste Version im Einsatz?");
std::cout << "OK" << std::endl;
}
void B15F::reconnect()
@ -73,12 +77,14 @@ void B15F::reconnect()
void B15F::discard(void)
{
tcflush(usart, TCIFLUSH); // leere Puffer
for(uint8_t i = 0; i < 8; i++)
{
writeByte(RQ_DISC); // sende discard Befehl (verwerfe input)
delay(1);
tcflush(usart, TCIFLUSH); // leere Puffer
delay(10);
}
delay(100);
tcflush(usart, TCIFLUSH); // leere Puffer
}
bool B15F::testConnection()
@ -240,7 +246,7 @@ bool B15F::analogEingabeSequenz(uint8_t channel_a, uint16_t* buffer_a, uint32_t
{
buffer_a[offset_a + i] = readInt();
buffer_b[offset_b + i] = readInt();
std::cout << "(" << i << ") " << buffer_a[offset_a + i] << " \t| " << buffer_b[offset_b + i] << std::endl;
//std::cout << "(" << i << ") " << buffer_a[offset_a + i] << " \t| " << buffer_b[offset_b + i] << std::endl;
}
aw = readByte();

Binary file not shown.

25
gnuplotscript.gp Normal file
View file

@ -0,0 +1,25 @@
set margin 10,10
unset key
set grid
set title ''
set xlabel 'UDrain [mV]'
set ylabel 'IDrain [mA]'
set xrange [0:5000]
set yrange [0:50]
set label at 2785,31 'UGS [Digit ] = 125' left
set label at 2663,28 'UGS [Digit ] = 150' left
set label at 2614,25 'UGS [Digit ] = 175' left
set label at 2541,18 'UGS [Digit ] = 200' left
set label at 2565,21 'UGS [Digit ] = 225' left
set label at 2468,13 'UGS [Digit ] = 250' left
set label at 2492,15 'UGS [Digit ] = 275' left
set label at 2443,11 'UGS [Digit ] = 300' left
set label at 2443,11 'UGS [Digit ] = 325' left
set label at 2394,8 'UGS [Digit ] = 350' left
set label at 2297,4 'UGS [Digit ] = 375' left
set label at 2297,4 'UGS [Digit ] = 400' left
set label at 2297,4 'UGS [Digit ] = 400' left
unset output
set terminal qt
unset output
plot "/tmp/tempfile0" using ($1*4.887586):($2*0.048876) binary format="%int16%int16" endian=big title 'UGS [Digit ] = 100' w l,"/tmp/tempfile1" using ($1*4.887586):($2*0.048876) binary format="%int16%int16" endian=big title 'UGS [Digit ] = 125' w l,"/tmp/tempfile2" using ($1*4.887586):($2*0.048876) binary format="%int16%int16" endian=big title 'UGS [Digit ] = 150' w l,"/tmp/tempfile3" using ($1*4.887586):($2*0.048876) binary format="%int16%int16" endian=big title 'UGS [Digit ] = 175' w l,"/tmp/tempfile4" using ($1*4.887586):($2*0.048876) binary format="%int16%int16" endian=big title 'UGS [Digit ] = 200' w l,"/tmp/tempfile5" using ($1*4.887586):($2*0.048876) binary format="%int16%int16" endian=big title 'UGS [Digit ] = 225' w l,"/tmp/tempfile6" using ($1*4.887586):($2*0.048876) binary format="%int16%int16" endian=big title 'UGS [Digit ] = 250' w l,"/tmp/tempfile7" using ($1*4.887586):($2*0.048876) binary format="%int16%int16" endian=big title 'UGS [Digit ] = 275' w l,"/tmp/tempfile8" using ($1*4.887586):($2*0.048876) binary format="%int16%int16" endian=big title 'UGS [Digit ] = 300' w l,"/tmp/tempfile9" using ($1*4.887586):($2*0.048876) binary format="%int16%int16" endian=big title 'UGS [Digit ] = 325' w l,"/tmp/tempfile10" using ($1*4.887586):($2*0.048876) binary format="%int16%int16" endian=big title 'UGS [Digit ] = 350' w l,"/tmp/tempfile11" using ($1*4.887586):($2*0.048876) binary format="%int16%int16" endian=big title 'UGS [Digit ] = 375' w l,"/tmp/tempfile12" using ($1*4.887586):($2*0.048876) binary format="%int16%int16" endian=big title 'UGS [Digit ] = 400' w l,"/tmp/tempfile13" using ($1*4.887586):($2*0.048876) binary format="%int16%int16" endian=big title 'UGS [Digit ] = 425' w l

BIN
graph Executable file

Binary file not shown.

BIN
main

Binary file not shown.

View file

@ -19,7 +19,9 @@ int main()
uint16_t ba[1024];
uint16_t bb[1024];
drv.analogEingabeSequenz(1, &ba[0], 0, 0, &bb[0], 0, 1000, -10, 101);
drv.analogEingabeSequenz(1, &ba[0], 0, 0, &bb[0], 0, 1023, -1, 1023);
system("./plotty --in graph");
std::cout << "Schluss." << std::endl;
}

BIN
main.o

Binary file not shown.

BIN
plotty Executable file

Binary file not shown.