diff --git a/src/C++/main.cpp b/src/C++/main.cpp index 8567ca7..2494251 100644 --- a/src/C++/main.cpp +++ b/src/C++/main.cpp @@ -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(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 \ No newline at end of file + + +//Tomorrow +//Try to use vectors and store every byte in its own array object by dividing the buffer into 8 bits \ No newline at end of file diff --git a/src/C++/main.o b/src/C++/main.o index aafde35..fc78527 100644 Binary files a/src/C++/main.o and b/src/C++/main.o differ diff --git a/src/C++/progr b/src/C++/progr index f4ed328..284b176 100755 Binary files a/src/C++/progr and b/src/C++/progr differ