cpp update

This commit is contained in:
2024-09-17 16:09:42 +02:00
parent d4b3beda6f
commit 03f1d2d8d0
3 changed files with 8 additions and 8 deletions

View File

@@ -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

Binary file not shown.

Binary file not shown.