Zwischenstand
This commit is contained in:
parent
dd58ec7fed
commit
b9d7caab28
47
drv/b15f.cpp
47
drv/b15f.cpp
|
@ -23,10 +23,10 @@ void B15F::init()
|
||||||
options.c_iflag = IGNPAR;
|
options.c_iflag = IGNPAR;
|
||||||
options.c_oflag = 0;
|
options.c_oflag = 0;
|
||||||
options.c_lflag = 0;
|
options.c_lflag = 0;
|
||||||
options.c_cc[VTIME]=1; // timeout in Dezisekunden
|
options.c_cc[VTIME]=100; // timeout in Dezisekunden
|
||||||
cfsetspeed(&options, BAUDRATE);
|
cfsetspeed(&options, BAUDRATE);
|
||||||
tcsetattr(usart, TCSANOW, &options);
|
tcsetattr(usart, TCSANOW, &options);
|
||||||
tcflush(usart, TCIFLUSH);
|
tcflush(usart, TCIOFLUSH); // leere Puffer in beiden Richtungen
|
||||||
|
|
||||||
std::cout << "OK" << std::endl;
|
std::cout << "OK" << std::endl;
|
||||||
|
|
||||||
|
@ -81,14 +81,13 @@ void B15F::reconnect()
|
||||||
|
|
||||||
void B15F::discard(void)
|
void B15F::discard(void)
|
||||||
{
|
{
|
||||||
tcflush(usart, TCIFLUSH); // leere Puffer
|
tcflush(usart, TCOFLUSH); // leere Ausgangspuffer
|
||||||
for(uint8_t i = 0; i < 8; i++)
|
for(uint8_t i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
writeByte(RQ_DISC); // sende discard Befehl (verwerfe input)
|
writeByte(RQ_DISC); // sende discard Befehl (verwerfe input)
|
||||||
delay(10);
|
delay((16000 / BAUDRATE) + 1); // warte mindestens eine Millisekunde, gegebenenfalls mehr
|
||||||
}
|
}
|
||||||
delay(100);
|
tcflush(usart, TCIFLUSH); // leere Eingangspuffer
|
||||||
tcflush(usart, TCIFLUSH); // leere Puffer
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool B15F::testConnection()
|
bool B15F::testConnection()
|
||||||
|
@ -272,23 +271,33 @@ bool B15F::analogEingabeSequenz(uint8_t channel_a, uint16_t* buffer_a, uint32_t
|
||||||
writeByte(channel_b);
|
writeByte(channel_b);
|
||||||
writeInt(start);
|
writeInt(start);
|
||||||
writeInt(static_cast<uint16_t>(delta));
|
writeInt(static_cast<uint16_t>(delta));
|
||||||
writeInt(count);
|
writeInt(count);
|
||||||
uint8_t aw = readByte();
|
uint8_t aw = readByte();
|
||||||
|
|
||||||
if(aw != MSG_OK)
|
if(aw != MSG_OK)
|
||||||
|
{
|
||||||
|
std::cout << PRE << "Mikrocontroller nicht synchronisiert" << std::endl;
|
||||||
throw DriverException("Mikrocontroller nicht synchronisiert");
|
throw DriverException("Mikrocontroller nicht synchronisiert");
|
||||||
|
}
|
||||||
|
|
||||||
for(uint16_t i = 0; i < count; i++)
|
for(uint16_t i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
buffer_a[offset_a + i] = readInt();
|
buffer_a[offset_a + i] = readInt();
|
||||||
buffer_b[offset_b + i] = readInt();
|
buffer_b[offset_b + i] = readInt();
|
||||||
if(buffer_a[offset_a + i] > 1023 || buffer_b[offset_b + i] > 1023)
|
if(buffer_a[offset_a + i] > 1023 || buffer_b[offset_b + i] > 1023)
|
||||||
std::cout << "schlechte Werte gefunden" << std::endl;
|
{
|
||||||
//std::cout << "(" << i << ") " << buffer_a[offset_a + i] << " \t| " << buffer_b[offset_b + i] << std::endl;
|
std::cout << PRE << "Schlechte Werte gefunden" << std::endl;
|
||||||
|
throw DriverException("Schlechte Werte gefunden");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
aw = readByte();
|
aw = readByte();
|
||||||
return aw == MSG_OK;
|
if(aw == MSG_OK)
|
||||||
|
return aw;
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
catch(DriverException& de)
|
catch(DriverException& de)
|
||||||
{
|
{
|
||||||
|
@ -318,10 +327,22 @@ uint8_t B15F::readByte()
|
||||||
uint16_t elapsed = 0;
|
uint16_t elapsed = 0;
|
||||||
while(elapsed < timeout)
|
while(elapsed < timeout)
|
||||||
{
|
{
|
||||||
int n = read(usart, &b, 1);
|
int n_ready;
|
||||||
if (n > 0)
|
int code = ioctl(usart, FIONREAD, &n_ready);
|
||||||
return static_cast<uint8_t>(b);
|
if(code != 0)
|
||||||
|
std::cout << PRE << "n_ready code: " << code << std::endl;
|
||||||
|
|
||||||
|
if(n_ready > 0)
|
||||||
|
{
|
||||||
|
//std::cout << code << " \tready: " << n_ready << std::endl;
|
||||||
|
|
||||||
|
code = read(usart, &b, 1);
|
||||||
|
if (code > 0)
|
||||||
|
return static_cast<uint8_t>(b);
|
||||||
|
if (code < 0)
|
||||||
|
std::cout << PRE << "usart code: " << code << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
end = std::chrono::steady_clock::now();
|
end = std::chrono::steady_clock::now();
|
||||||
elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
|
elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include "driverexception.h"
|
#include "driverexception.h"
|
||||||
|
|
||||||
|
@ -51,7 +52,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int usart = -1;
|
int usart = -1;
|
||||||
uint16_t timeout = 1000;
|
uint16_t timeout = 100; // ms
|
||||||
|
|
||||||
static B15F* instance;
|
static B15F* instance;
|
||||||
|
|
||||||
|
|
BIN
drv/b15f.o
BIN
drv/b15f.o
Binary file not shown.
|
@ -8,27 +8,28 @@ set xrange [5:0]
|
||||||
set x2range [5:0]
|
set x2range [5:0]
|
||||||
set y2range [0:50]
|
set y2range [0:50]
|
||||||
set yrange [0:50]
|
set yrange [0:50]
|
||||||
set label at 2,33 'U_{DS} [V] = 300' right
|
set label at 2,38 'U_{DS} [V] = 300' right
|
||||||
set label at 2,30 'U_{DS} [V] = 325' right
|
set label at 2,29 'U_{DS} [V] = 325' right
|
||||||
set label at 2,33 'U_{DS} [V] = 350' right
|
set label at 2,31 'U_{DS} [V] = 350' right
|
||||||
set label at 2,35 'U_{DS} [V] = 375' right
|
set label at 2,32 'U_{DS} [V] = 375' right
|
||||||
set label at 2,21 'U_{DS} [V] = 400' right
|
set label at 2,33 'U_{DS} [V] = 400' right
|
||||||
set label at 2,21 'U_{DS} [V] = 425' right
|
set label at 2,20 'U_{DS} [V] = 425' right
|
||||||
set label at 2,22 'U_{DS} [V] = 450' right
|
set label at 2,20 'U_{DS} [V] = 450' right
|
||||||
set label at 2,22 'U_{DS} [V] = 475' right
|
set label at 2,11 'U_{DS} [V] = 475' right
|
||||||
set label at 2,22 'U_{DS} [V] = 500' right
|
set label at 2,21 'U_{DS} [V] = 500' right
|
||||||
set label at 2,5 'U_{DS} [V] = 525' right
|
set label at 2,21 'U_{DS} [V] = 525' right
|
||||||
set label at 2,11 'U_{DS} [V] = 550' right
|
set label at 2,11 'U_{DS} [V] = 550' right
|
||||||
set label at 2,11 'U_{DS} [V] = 575' right
|
set label at 2,11 'U_{DS} [V] = 575' right
|
||||||
set label at 2,11 'U_{DS} [V] = 600' right
|
set label at 2,11 'U_{DS} [V] = 600' right
|
||||||
set label at 2,11 'U_{DS} [V] = 625' right
|
set label at 2,11 'U_{DS} [V] = 600' right
|
||||||
set label at 2,4 'U_{DS} [V] = 650' right
|
set label at 2,11 'U_{DS} [V] = 600' right
|
||||||
set label at 2,4 'U_{DS} [V] = 650' right
|
set label at 2,11 'U_{DS} [V] = 600' right
|
||||||
set label at 2,4 'U_{DS} [V] = 700' right
|
set label at 2,11 'U_{DS} [V] = 600' right
|
||||||
|
set label at 2,11 'U_{DS} [V] = 600' right
|
||||||
set y2tics
|
set y2tics
|
||||||
unset ytics
|
unset ytics
|
||||||
set ytics format ''
|
set ytics format ''
|
||||||
unset output
|
unset output
|
||||||
set terminal qt
|
set terminal qt
|
||||||
unset output
|
unset output
|
||||||
plot "/tmp/tempfile1" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 300' w l,"/tmp/tempfile2" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 325' w l,"/tmp/tempfile3" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 350' w l,"/tmp/tempfile4" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 375' w l,"/tmp/tempfile5" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 400' w l,"/tmp/tempfile6" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 425' w l,"/tmp/tempfile7" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 450' w l,"/tmp/tempfile8" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 475' w l,"/tmp/tempfile9" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 500' w l,"/tmp/tempfile10" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 525' w l,"/tmp/tempfile11" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 550' w l,"/tmp/tempfile12" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 575' w l,"/tmp/tempfile13" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 600' w l,"/tmp/tempfile14" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 625' w l,"/tmp/tempfile15" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 650' w l,"/tmp/tempfile16" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 675' w l,"/tmp/tempfile17" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 700' w l
|
plot "/tmp/tempfile1" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 300' w l,"/tmp/tempfile2" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 325' w l,"/tmp/tempfile3" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 350' w l,"/tmp/tempfile4" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 375' w l,"/tmp/tempfile5" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 400' w l,"/tmp/tempfile6" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 425' w l,"/tmp/tempfile7" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 450' w l,"/tmp/tempfile8" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 475' w l,"/tmp/tempfile9" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 500' w l,"/tmp/tempfile10" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 525' w l,"/tmp/tempfile11" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 550' w l,"/tmp/tempfile12" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 575' w l,"/tmp/tempfile13" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 600' w l,"/tmp/tempfile14" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 625' w l,"/tmp/tempfile15" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 650' w l,"/tmp/tempfile16" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 675' w l,"/tmp/tempfile17" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 700' w l,"/tmp/tempfile18" using ($1*0.004888):($2*0.048876) binary format="%int16%int16" endian=big title 'U_{DS} [V] = 725' w l
|
||||||
|
|
3
main.cpp
3
main.cpp
|
@ -82,9 +82,6 @@ void kennlinieZweiterQuadrant()
|
||||||
drv.analogeAusgabe1(u_gs);
|
drv.analogeAusgabe1(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.discard();
|
|
||||||
drv.delay(10);
|
|
||||||
|
|
||||||
curve = 0;
|
curve = 0;
|
||||||
for(uint16_t k = 0; k < sample_count + 1; k++)
|
for(uint16_t k = 0; k < sample_count + 1; k++)
|
||||||
|
|
Loading…
Reference in a new issue