Search code examples
c++node.jsraspberry-pinativeuart

C Pigpio: read bit bang serial


I want to bit bang read from a UART Rx pin with C++ (actually developing a nodejs native module for this). I can successfully initialise the pigpio library, but when I try to read with this code:

gpioSerialReadOpen(TXD, 9600, 8);
while(true){ 
   gsr = gpioSerialRead(TXD, buf, 8);
   if(gsr < 0) {
      printf("%d\n", gsr);
   }else{
      fwrite(buf, 8, 1, stdout);
   }
   sleep(100);
}

I only get a 4-digit number read every time (the number is the same every application instance - when I restart the program, the number changes). What am I doing wrong?


Solution

  • Finally fixed the problem, I forgot about setting the pin mode to input