Version 0.1

This commit is contained in:
Tristan Krause 2019-03-29 15:06:35 +01:00
parent bd80e3dbf7
commit 6dd836c729
9 changed files with 28 additions and 29 deletions

View file

@ -140,6 +140,7 @@ std::vector<std::string> B15F::getBoardInfo(void)
bool B15F::digitalWrite0(uint8_t port)
{
usart.clearInputBuffer();
usart.writeByte(RQ_BA0);
usart.writeByte(port);
@ -149,6 +150,7 @@ bool B15F::digitalWrite0(uint8_t port)
bool B15F::digitalWrite1(uint8_t port)
{
usart.clearInputBuffer();
usart.writeByte(RQ_BA1);
usart.writeByte(port);
@ -158,18 +160,21 @@ bool B15F::digitalWrite1(uint8_t port)
uint8_t B15F::digitalRead0()
{
usart.clearInputBuffer();
usart.writeByte(RQ_BE0);
return usart.readByte();
}
uint8_t B15F::digitalRead1()
{
usart.clearInputBuffer();
usart.writeByte(RQ_BE1);
return usart.readByte();
}
bool B15F::analogWrite0(uint16_t value)
{
usart.clearInputBuffer();
usart.writeByte(RQ_AA0);
usart.writeInt(value);
@ -179,6 +184,7 @@ bool B15F::analogWrite0(uint16_t value)
bool B15F::analogWrite1(uint16_t value)
{
usart.clearInputBuffer();
usart.writeByte(RQ_AA1);
usart.writeInt(value);
@ -188,6 +194,7 @@ bool B15F::analogWrite1(uint16_t value)
uint16_t B15F::analogRead(uint8_t channel)
{
usart.clearInputBuffer();
usart.writeByte(RQ_ADC);
usart.writeByte(channel);
return usart.readInt();
@ -198,6 +205,7 @@ bool B15F::analogSequence(uint8_t channel_a, uint16_t* buffer_a, uint32_t offset
buffer_a += offset_a;
buffer_b += offset_b;
usart.clearInputBuffer();
usart.writeByte(RQ_ADC_DAC_STROKE);
usart.writeByte(channel_a);
usart.writeByte(channel_b);

View file

@ -91,6 +91,8 @@ public:
/*************************************/
/*************************
* Steuerbefehle für B15 *
*************************/

Binary file not shown.

View file

@ -51,14 +51,15 @@ void USART::clearOutputBuffer()
void USART::writeByte(uint8_t b)
{
//std::cout << "write(): " << (int) b << std::endl;
if(write(file_desc, &b, 1) != 1)
int sent = write(file_desc, &b, 1);
if(sent != 1)
throw USARTException("Fehler beim Senden: writeByte()");
}
void USART::writeInt(uint16_t d)
{
if(write(file_desc, reinterpret_cast<char*>(&d), 2) != 2)
int sent = write(file_desc, reinterpret_cast<char*>(&d), 2);
if(sent != 2)
throw USARTException("Fehler beim Senden: writeInt()");
}
@ -102,28 +103,15 @@ uint8_t USART::readByte(void)
uint16_t elapsed = 0;
while(elapsed < timeout * 100)
{
int n_ready;
int code = ioctl(file_desc, FIONREAD, &n_ready);
if(code != 0)
std::cout << "n_ready code: " << code << std::endl;
if(n_ready > 0)
{
//std::cout << code << " \tready: " << n_ready << std::endl;
code = read(file_desc, &b, 1);
if (code > 0)
return static_cast<uint8_t>(b);
if (code < 0)
std::cout << "usart code: " << code << std::endl;
}
int code = read(file_desc, &b, 1);
if (code > 0)
return static_cast<uint8_t>(b);
end = std::chrono::steady_clock::now();
elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
}
if(elapsed >= timeout)
throw USARTException("Verbindung unterbrochen. (timeout)");
throw TimeoutException("Verbindung unterbrochen.", timeout);
}
uint16_t USART::readInt(void)

View file

@ -9,6 +9,7 @@
#include <sys/ioctl.h>
#include <termios.h>
#include "usartexception.h"
#include "timeoutexception.h"
class USART
{

Binary file not shown.

View file

@ -10,20 +10,20 @@ set y2range [0:50]
set yrange [0:50]
set label at 2,36 'U_{DS} [V] = 300' right
set label at 2,33 'U_{DS} [V] = 325' right
set label at 2,36 'U_{DS} [V] = 350' right
set label at 2,21 'U_{DS} [V] = 350' right
set label at 2,38 'U_{DS} [V] = 375' right
set label at 2,5 'U_{DS} [V] = 400' right
set label at 2,23 'U_{DS} [V] = 400' right
set label at 2,23 'U_{DS} [V] = 425' right
set label at 2,24 'U_{DS} [V] = 450' right
set label at 2,24 'U_{DS} [V] = 475' right
set label at 2,12 'U_{DS} [V] = 500' right
set label at 2,13 'U_{DS} [V] = 525' right
set label at 2,13 'U_{DS} [V] = 550' right
set label at 2,25 'U_{DS} [V] = 500' right
set label at 2,5 'U_{DS} [V] = 525' right
set label at 2,6 'U_{DS} [V] = 550' right
set label at 2,13 'U_{DS} [V] = 575' right
set label at 2,13 'U_{DS} [V] = 600' right
set label at 2,6 'U_{DS} [V] = 625' right
set label at 2,6 'U_{DS} [V] = 650' right
set label at 2,6 'U_{DS} [V] = 675' right
set label at 2,13 'U_{DS} [V] = 625' right
set label at 2,2 'U_{DS} [V] = 650' right
set label at 2,2 'U_{DS} [V] = 675' right
set label at 2,6 'U_{DS} [V] = 700' right
set label at 2,2 'U_{DS} [V] = 725' right
set label at 2,2 'U_{DS} [V] = 725' right

BIN
main

Binary file not shown.

BIN
test_plot

Binary file not shown.