mirror of
https://github.com/clockworkpi/WiringPi.git
synced 2025-12-13 16:18:52 +01:00
delayMicrosecondsHard re-written - again. Added a serialRead example program, and added in the okLed to the examples too. Updated/checked some of the GPIO/PWM code. Added in some experimental servo and tone generating code and and example or 2. Tweaks to the gpio command to correctly load the I2C modules too.
32 lines
472 B
C
32 lines
472 B
C
|
|
/*
|
|
* serialRead.c:
|
|
* Example program to read bytes from the Serial line
|
|
*
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
|
|
#include <wiringSerial.h>
|
|
|
|
int main ()
|
|
{
|
|
int fd ;
|
|
|
|
if ((fd = serialOpen ("/dev/ttyAMA0", 115200)) < 0)
|
|
{
|
|
fprintf (stderr, "Unable to open serial device: %s\n", strerror (errno)) ;
|
|
return 1 ;
|
|
}
|
|
|
|
// Loop, getting and printing characters
|
|
|
|
for (;;)
|
|
{
|
|
putchar (serialGetchar (fd)) ;
|
|
fflush (stdout) ;
|
|
}
|
|
}
|