mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-03 11:55:00 +00:00
cpp update
This commit is contained in:
@@ -5,7 +5,7 @@ int main() {
|
||||
char byte;
|
||||
bool foundAA = false;
|
||||
bool capture = false;
|
||||
char buffer[200];
|
||||
unsigned int buffer;
|
||||
std::ifstream f("/dev/ttyUSB0", std::ios::binary);
|
||||
if (!f.is_open()) {
|
||||
std::cerr << "Failed to open the file" << std::endl;
|
||||
@@ -15,21 +15,18 @@ int main() {
|
||||
while (f.read(&byte, 1)) {
|
||||
unsigned char ubyte = static_cast<unsigned char>(byte);
|
||||
if (foundAA) {
|
||||
capture = true;
|
||||
if (ubyte == 0b01010101) { // 0x55
|
||||
std::cout << "Found 0xAA followed by 0x55" << std::endl;
|
||||
memset(buffer, 0, sizeof(buffer)); // Clear the buffer
|
||||
std::cout << buffer.sizeof << std::endl;
|
||||
buffer = 0;
|
||||
foundAA = false; // Reset the state
|
||||
} else {
|
||||
foundAA = false; // Reset the state if the next byte is not 0x55
|
||||
capture = false; // Stop capturing
|
||||
}
|
||||
} else if (ubyte == 0b10101010) { // 0xAA
|
||||
foundAA = true;
|
||||
}
|
||||
if (capture) {
|
||||
std::cout << buffer[200] << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
f.close();
|
||||
@@ -37,4 +34,7 @@ int main() {
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
|
||||
|
||||
//Tomorrow
|
||||
//Try to use vectors and store every byte in its own array object by dividing the buffer into 8 bits
|
BIN
src/C++/main.o
BIN
src/C++/main.o
Binary file not shown.
BIN
src/C++/progr
BIN
src/C++/progr
Binary file not shown.
Reference in New Issue
Block a user