I connect a QR-Code-Scanner to my Linux-PC over USB in USB-COM-Mode. When I do so, a file is created: /dev/serial/by-id/usb-Datalogic_ADC__Inc._Handheld_Barcode_Scanner_S_N_E18C59366.-if00
I read from this file like so:
#include <iostream>
#include <fstream>
#include <string>
#include <unistd.h>
using namespace std;
int main () {
while (1) {
ifstream bufferLink("/dev/serial/by-id/usb-Datalogic_ADC__Inc._Handheld_Barcode_Scanner_S_N_E18C59366.-if00");
if (bufferLink.is_open()) {
string line;
while (!bufferLink.eof()) {
cout << "Waiting for input: " << endl;
getline(bufferLink, line);
cout << "+++++++++ Line: " << line << endl;
}
}
}
usleep(1000*1000);
return 0;
}
I then created a QR-Code with the Data: Andre Mantei ist der Beste.
But when I read the QR-Code with my Scanner it gives me a lot of additional output:
Waiting for input:
+++++++++ Line: Andre Mantei ist der Beste.
Waiting for input:
+++++++++ Line:
Waiting for input:
+++++++++ Line:
Waiting for input:
+++++++++ Line: !"#$%&'()*+,-./0123456789:;<=>?@
Waiting for input:
+++++++++ Line:
Waiting for input:
+++++++++ Line: ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`
Waiting for input:
+++++++++ Line:
Waiting for input:
+++++++++ Line: abcdefghijklmnopqrstuvwxyz{|}
Waiting for input:
+++++++++ Line:
Waiting for input:
+++++++++ Line:
Waiting for input:
+++++++++ Line:
Waiting for input:
+++++++++ Line:
Waiting for input:
+++++++++ Line:
Waiting for input:
+++++++++ Line:
Waiting for input:
+++++++++ Line: !"#$%&'()*+,-./0123456789:;<=>?@
Waiting for input:
+++++++++ Line:
Waiting for input:
+++++++++ Line: ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`
Waiting for input:
+++++++++ Line:
Waiting for input:
+++++++++ Line: abcdefghijklmnopqrstuvwxyz{|}
Waiting for input:
+++++++++ Line:
Waiting for input:
It happens not always but most of the time. Can anyone explain that behavior ?