From bb1904b125f987ec8889ed718eda5934f0a480c3 Mon Sep 17 00:00:00 2001 From: "ishak jmilou.ishak" Date: Mon, 6 Jan 2025 09:53:01 +0100 Subject: [PATCH] commentaar naar engels --- src/C++/Driver/src/KobukiDriver/CKobuki.cpp | 41 ++++++++++----------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/C++/Driver/src/KobukiDriver/CKobuki.cpp b/src/C++/Driver/src/KobukiDriver/CKobuki.cpp index 429e7f9..1d82a4e 100755 --- a/src/C++/Driver/src/KobukiDriver/CKobuki.cpp +++ b/src/C++/Driver/src/KobukiDriver/CKobuki.cpp @@ -68,7 +68,7 @@ int CKobuki::connect(char *comportT) { HCom = open(comportT, O_RDWR | O_NOCTTY | O_NONBLOCK); if (HCom == -1) { - printf("Kobuki nepripojeny\n"); + printf("Kobuki connected\n"); return HCom; } else { set_interface_attribs2(HCom, B115200, @@ -89,7 +89,7 @@ int CKobuki::connect(char *comportT) { tcsetattr(HCom, TCSANOW, &settings); // apply the settings*/ tcflush(HCom, TCOFLUSH); - printf("Kobuki pripojeny\n"); + printf("Kobuki connected\n"); return HCom; } } @@ -99,27 +99,26 @@ unsigned char *CKobuki::readKobukiMessage() { ssize_t Pocet; buffer[0] = 0; unsigned char *null_buffer(0); - // citame kym nezachytime zaciatok spravy + + // Read until the start of the message is detected do { Pocet = read(HCom, buffer, 1); } while (buffer[0] != 0xAA); - // mame zaciatok spravy (asi) + + // We have the start of the message (possibly) if (Pocet == 1 && buffer[0] == 0xAA) { - // citame dalsi byte + // Read the next byte do { - Pocet = read(HCom, buffer, 1); + } while (Pocet != 1); // On Linux: -1, on Windows: 0 - } while (Pocet != 1); // na linuxe -1 na windowse 0 - - // a ak je to druhy byte hlavicky + // If it is the second byte of the header if (Pocet == 1 && buffer[0] == 0x55) { - // precitame dlzku + // Read the length Pocet = read(HCom, buffer, 1); - // ReadFile(hCom, buffer, 1, &Pocet, NULL); if (Pocet == 1) { - // mame dlzku.. nastavime vektor a precitame ho cely + // We have the length; initialize a buffer and read the entire message int readLenght = buffer[0]; unsigned char *outputBuffer = (unsigned char *)calloc(readLenght + 4, sizeof(char)); @@ -134,7 +133,7 @@ unsigned char *CKobuki::readKobukiMessage() { pct = pct + (Pocet == -1 ? 0 : Pocet); } while (pct != (readLenght + 1)); - // tu si mozeme ceknut co chodi zo serial intefejsu Kobukiho + // Here we can check what data is received from the Kobuki's serial interface // for(int i=0;i