Greyhaired:
Allerdings, das sind Werte aus dem Saleae-Analyzer-Programm. Wie ich sie mittels Arduino auslese und bearbeite, muß ich mir erst erarbeiten.
Wenn Du eine Anregung benötigst:
/*
0xFF
"&7- 0,7ms H+0019m0019m 5,5V 000.0"
0x00
0xFF
"&7 0,0ms H+0017m0021m 5,5V 000.0"
0x00
0xFF
"&7+ 0,1ms H+0021m0021m 5,5V 000.0"
0x00
*/
#include <Streaming.h>
char receivedChars1[] = {"&7- 0,7ms H+0019m0019m 5,5V 000.0"};
char receivedChars2[] = {"&7 0,0ms H-0017m0021m 5,5V 000.0"};
char receivedChars3[] = {"&7+ 0,1ms H+0021m0021m 5,5V 000.0"};
void setup()
{
Serial.begin(9600);
Serial.println(F("Anfang"));
ausgabe(receivedChars1);
ausgabe(receivedChars2);
ausgabe(receivedChars3);
}
void ausgabe(char* text) {
Serial << text << endl;
char dir;
byte a1 = 0, a2 = 0, s1 = 0, s2 = 0; // Hier sollen die Zahlenwerte landen
short int h1 = 0, h2 = 0;
sscanf(text, "&7%c %hhu,%hhums H%hdm%hdm %hhu,%hhuV 000.0", &dir, &a1, &a2, &h1, &h2, &s1, &s2);
Serial << "dir: " << dir << "\ta1: " << a1 << "\ta2: " << a2 << "\th1: " << h1 << "\th2: " << h2 << "\ts1: " << s1 << "\ts2: " << s2 << endl;
float stg = a1 + (a2 / 10.);
float spg = s1 + (s2 / 10.);
Serial << "Richtung: " << dir << "\tSteigung: " << stg << "\tHoehe: " << h1 << "\tSpannung: " << spg << endl;
// Fuer die folgenden Zeilen ist eine Erweiterung der IDE notwendig, damit %f funktioniert.
// Quelle: https://forum.arduino.cc/index.php?topic=570408.msg3888254#msg3888254
char* pos = strchr(text, (int)',');
*pos = '.';
pos = strchr(text, (int)',');
*pos = '.';
Serial << text << endl;
float af = 0, sf = 0;
sscanf(text, "&7%c %fms H%hdm%hdm %fV 000.0", &dir, &af, &h1, &h2, &sf); // hier %f
Serial << "dir: " << dir << "\taf: " << af << "\th1: " << h1 << "\th2: " << h2 << "\tsf: " << sf << endl;
// Ende notwendige Erweiterung.
Serial.println(F("-------"));
}
void loop()
{}