mirror of
git://soft.sys114.com/WiringPi2-Python
synced 2026-02-07 00:19:48 +09:00
Big update here.
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.
This commit is contained in:
31
examples/serialRead.c
Normal file
31
examples/serialRead.c
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
/*
|
||||
* 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) ;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user