Browse Source

Changes to remove warnings generated by gcc 8.2.

pull/61/head
grumpy-dude 6 years ago
parent
commit
b362a677ab
44 changed files with 562 additions and 365 deletions
  1. +6
    -6
      devLib/lcd.c
  2. +13
    -13
      devLib/maxdetect.c
  3. +3
    -3
      examples/Gertboard/vumeter.c
  4. +7
    -7
      examples/PiFace/ladder.c
  5. +3
    -3
      examples/PiGlow/piGlow1.c
  6. +4
    -4
      examples/PiGlow/piglow.c
  7. +9
    -9
      examples/clock.c
  8. +11
    -11
      examples/lcd-adafruit.c
  9. +7
    -7
      examples/lcd.c
  10. +4
    -4
      examples/spiSpeed.c
  11. +1
    -1
      gpio/Makefile
  12. +80
    -40
      gpio/gpio.c
  13. +3
    -3
      gpio/readall.c
  14. +1
    -1
      wiringPi/Makefile
  15. +2
    -2
      wiringPi/ads1115.c
  16. +2
    -2
      wiringPi/bmp180.c
  17. +36
    -22
      wiringPi/drcNet.c
  18. +5
    -5
      wiringPi/drcSerial.c
  19. +3
    -3
      wiringPi/ds18b20.c
  20. +4
    -4
      wiringPi/htu21d.c
  21. +2
    -2
      wiringPi/max31855.c
  22. +2
    -2
      wiringPi/max5322.c
  23. +2
    -2
      wiringPi/mcp23008.c
  24. +2
    -2
      wiringPi/mcp23016.c
  25. +2
    -2
      wiringPi/mcp23017.c
  26. +2
    -2
      wiringPi/mcp23s08.c
  27. +2
    -2
      wiringPi/mcp23s17.c
  28. +2
    -2
      wiringPi/mcp3002.c
  29. +2
    -2
      wiringPi/mcp3004.c
  30. +25
    -5
      wiringPi/mcp3422.c
  31. +2
    -2
      wiringPi/mcp4802.c
  32. +2
    -2
      wiringPi/pcf8574.c
  33. +19
    -6
      wiringPi/pcf8591.c
  34. +3
    -3
      wiringPi/pseudoPins.c
  35. +11
    -11
      wiringPi/rht03.c
  36. +2
    -2
      wiringPi/sn3218.c
  37. +1
    -1
      wiringPi/sr595.c
  38. +139
    -66
      wiringPi/wiringPi.c
  39. +17
    -7
      wiringPi/wiringPi.h
  40. +29
    -2
      wiringPi/wiringSerial.c
  41. +83
    -83
      wiringPi/wpiExtensions.c
  42. +2
    -2
      wiringPiD/network.c
  43. +1
    -1
      wiringPiD/runRemote.c
  44. +4
    -4
      wiringPiD/wiringpid.c

+ 6
- 6
devLib/lcd.c View File

@@ -32,9 +32,9 @@

#include "lcd.h"

#ifndef TRUE
# define TRUE (1==1)
# define FALSE (1==2)
#ifndef true
# define true (1==1)
# define false (1==2)
#endif

// HD44780U Commands
@@ -483,9 +483,9 @@ int lcdInit (const int rows, const int cols, const int bits,

// Rest of the initialisation sequence

lcdDisplay (lcdFd, TRUE) ;
lcdCursor (lcdFd, FALSE) ;
lcdCursorBlink (lcdFd, FALSE) ;
lcdDisplay (lcdFd, true) ;
lcdCursor (lcdFd, false) ;
lcdCursorBlink (lcdFd, false) ;
lcdClear (lcdFd) ;

putCommand (lcd, LCD_ENTRY | LCD_ENTRY_ID) ;


+ 13
- 13
devLib/maxdetect.c View File

@@ -31,9 +31,9 @@

#include "maxdetect.h"

#ifndef TRUE
# define TRUE (1==1)
# define FALSE (1==2)
#ifndef true
# define true (1==1)
# define false (1==2)
#endif


@@ -58,7 +58,7 @@ static int maxDetectLowHighWait (const int pin)
{
gettimeofday (&now, NULL) ;
if (timercmp (&now, &timeUp, >))
return FALSE ;
return false ;
}

// Wait for it to go HIGH
@@ -72,10 +72,10 @@ static int maxDetectLowHighWait (const int pin)
{
gettimeofday (&now, NULL) ;
if (timercmp (&now, &timeUp, >))
return FALSE ;
return false ;
}

return TRUE ;
return true ;
}


@@ -110,7 +110,7 @@ static unsigned int maxDetectClockByte (const int pin)
/*
* maxDetectRead:
* Read in and return the 4 data bytes from the MaxDetect sensor.
* Return TRUE/FALSE depending on the checksum validity
* Return true/false depending on the checksum validity
*********************************************************************************
*/

@@ -136,7 +136,7 @@ int maxDetectRead (const int pin, unsigned char buffer [4])
// Now wait for sensor to pull pin low

if (!maxDetectLowHighWait (pin))
return FALSE ;
return false ;

// and read in 5 bytes (40 bits)

@@ -165,7 +165,7 @@ int maxDetectRead (const int pin, unsigned char buffer [4])
// reading is probably bogus.

if ((took.tv_sec != 0) || (took.tv_usec > 16000))
return FALSE ;
return false ;

return checksum == localBuf [4] ;
}
@@ -196,7 +196,7 @@ int readRHT03 (const int pin, int *temp, int *rh)
{
*rh = lastRh ;
*temp = lastTemp ;
return TRUE ;
return true ;
}

// Set timeout for next read
@@ -214,7 +214,7 @@ int readRHT03 (const int pin, int *temp, int *rh)
result = maxDetectRead (pin, buffer) ;

if (!result)
return FALSE ;
return false ;

*rh = (buffer [0] * 256 + buffer [1]) ;
*temp = (buffer [2] * 256 + buffer [3]) ;
@@ -229,10 +229,10 @@ int readRHT03 (const int pin, int *temp, int *rh)
// (which does seem to happen - no realtime here)

if ((*rh > 999) || (*temp > 800) || (*temp < -400))
return FALSE ;
return false ;

lastRh = *rh ;
lastTemp = *temp ;

return TRUE ;
return true ;
}

+ 3
- 3
examples/Gertboard/vumeter.c View File

@@ -23,9 +23,9 @@
#include <wiringPi.h>
#include <gertboard.h>

#ifndef TRUE
#define TRUE (1==1)
#define FALSE (!TRUE)
#ifndef true
#define true (1==1)
#define false (!true)
#endif

#define B_SIZE 1000


+ 7
- 7
examples/PiFace/ladder.c View File

@@ -13,9 +13,9 @@
#include <wiringPi.h>
#include <piFace.h>

#ifndef TRUE
# define TRUE (1==1)
# define FALSE (1==2)
#ifndef true
# define true (1==1)
# define false (1==2)
#endif

#undef DEBUG
@@ -244,7 +244,7 @@ void ledOnAction (void)
if (digitalRead (PIFACE) == LOW)
{
chargeCapacitor () ;
ledBargraph (vCap, TRUE) ;
ledBargraph (vCap, true) ;
}
}

@@ -264,7 +264,7 @@ void ledOffAction (void)
if (digitalRead (PIFACE) == LOW)
{
vCap = vCapLast = 0.0 ;
ledBargraph (vCap, FALSE) ;
ledBargraph (vCap, false) ;

// Wait until we release the button

@@ -300,7 +300,7 @@ int main (void)

// LED ON:

(void)ledBargraph (vCap, TRUE) ;
(void)ledBargraph (vCap, true) ;
then = millis () + ledOnTime ;
while (millis () < then)
{
@@ -323,7 +323,7 @@ int main (void)

// LED OFF:

(void)ledBargraph (vCap, FALSE) ;
(void)ledBargraph (vCap, false) ;
then = millis () + ledOffTime ;
while (millis () < then)
{


+ 3
- 3
examples/PiGlow/piGlow1.c View File

@@ -32,9 +32,9 @@

#define PIGLOW_BASE 533

#ifndef TRUE
# define TRUE (1==1)
# define FALSE (!TRUE)
#ifndef true
# define true (1==1)
# define false (!true)
#endif




+ 4
- 4
examples/PiGlow/piglow.c View File

@@ -27,9 +27,9 @@
#include <string.h>
#include <stdlib.h>

#ifndef TRUE
# define TRUE (1==1)
# define FALSE (!TRUE)
#ifndef true
# define true (1==1)
# define false (!true)
#endif

#include <wiringPi.h>
@@ -81,7 +81,7 @@ int main (int argc, char *argv [])

// Initialise the piGlow devLib

piGlowSetup (FALSE) ;
piGlowSetup (false) ;

if (argc == 1)
failUsage () ;


+ 9
- 9
examples/clock.c View File

@@ -45,9 +45,9 @@
#include <wiringPi.h>
#include <lcd128x64.h>

#ifndef TRUE
# define TRUE (1==1)
# define FALSE (1==2)
#ifndef true
# define true (1==1)
# define false (1==2)
#endif

double clockRadius ;
@@ -130,15 +130,15 @@ void drawClockFace (void)
double d, px1, py1, px2, py2 ;

lcd128x64clear (0) ;
lcd128x64circle (0,0, clockRadius, 1, TRUE) ;
lcd128x64circle (0,0, clockRadius - thickness, 0, TRUE) ;
lcd128x64circle (0,0, clockRadius, 1, true) ;
lcd128x64circle (0,0, clockRadius - thickness, 0, true) ;

// The four big indicators for 12,15,30 and 45

lcd128x64rectangle (- 3, clockRadius - barLen, 3, clockRadius, 1, TRUE) ; // 12
lcd128x64rectangle (clockRadius - barLen, 3, clockRadius, -3, 1, TRUE) ; // 3
lcd128x64rectangle (- 3, -clockRadius + barLen, 3, -clockRadius, 1, TRUE) ; // 6
lcd128x64rectangle (-clockRadius + barLen, 3, -clockRadius, -3, 1, TRUE) ; // 9
lcd128x64rectangle (- 3, clockRadius - barLen, 3, clockRadius, 1, true) ; // 12
lcd128x64rectangle (clockRadius - barLen, 3, clockRadius, -3, 1, true) ; // 3
lcd128x64rectangle (- 3, -clockRadius + barLen, 3, -clockRadius, 1, true) ; // 6
lcd128x64rectangle (-clockRadius + barLen, 3, -clockRadius, -3, 1, true) ; // 9


// Smaller 5 and 1 minute ticks


+ 11
- 11
examples/lcd-adafruit.c View File

@@ -34,9 +34,9 @@
#include <mcp23017.h>
#include <lcd.h>

#ifndef TRUE
# define TRUE (1==1)
# define FALSE (1==2)
#ifndef true
# define true (1==1)
# define false (1==2)
#endif


@@ -251,7 +251,7 @@ int main (int argc, char *argv[])
{
int colour ;
int cols = 16 ;
int waitForRelease = FALSE ;
int waitForRelease = false ;

struct tm *t ;
time_t tim ;
@@ -287,13 +287,13 @@ int main (int argc, char *argv[])
lcdPuts (lcdHandle, "User Char: ") ;
lcdPutchar (lcdHandle, 2) ;

lcdCursor (lcdHandle, TRUE) ;
lcdCursorBlink (lcdHandle, TRUE) ;
lcdCursor (lcdHandle, true) ;
lcdCursorBlink (lcdHandle, true) ;

waitForEnter () ;

lcdCursor (lcdHandle, FALSE) ;
lcdCursorBlink (lcdHandle, FALSE) ;
lcdCursor (lcdHandle, false) ;
lcdCursorBlink (lcdHandle, false) ;

speedTest () ;

@@ -320,7 +320,7 @@ int main (int argc, char *argv[])
if ((digitalRead (AF_UP) == LOW) || (digitalRead (AF_DOWN) == LOW))
continue ;
else
waitForRelease = FALSE ;
waitForRelease = false ;
}

if (digitalRead (AF_UP) == LOW) // Pushed
@@ -329,7 +329,7 @@ int main (int argc, char *argv[])
if (colour == 8)
colour = 0 ;
setBacklightColour (colour) ;
waitForRelease = TRUE ;
waitForRelease = true ;
}

if (digitalRead (AF_DOWN) == LOW) // Pushed
@@ -338,7 +338,7 @@ int main (int argc, char *argv[])
if (colour == -1)
colour = 7 ;
setBacklightColour (colour) ;
waitForRelease = TRUE ;
waitForRelease = true ;
}

}


+ 7
- 7
examples/lcd.c View File

@@ -47,9 +47,9 @@
#include <wiringPi.h>
#include <lcd.h>

#ifndef TRUE
# define TRUE (1==1)
# define FALSE (1==2)
#ifndef true
# define true (1==1)
# define false (1==2)
#endif

static unsigned char newChar [8] =
@@ -247,13 +247,13 @@ int main (int argc, char *argv[])
lcdPuts (lcdHandle, "User Char: ") ;
lcdPutchar (lcdHandle, 2) ;

lcdCursor (lcdHandle, TRUE) ;
lcdCursorBlink (lcdHandle, TRUE) ;
lcdCursor (lcdHandle, true) ;
lcdCursorBlink (lcdHandle, true) ;

waitForEnter () ;

lcdCursor (lcdHandle, FALSE) ;
lcdCursorBlink (lcdHandle, FALSE) ;
lcdCursor (lcdHandle, false) ;
lcdCursorBlink (lcdHandle, false) ;
lcdClear (lcdHandle) ;

for (;;)


+ 4
- 4
examples/spiSpeed.c View File

@@ -36,8 +36,8 @@
#include <wiringPi.h>
#include <wiringPiSPI.h>

#define TRUE (1==1)
#define FALSE (!TRUE)
#define true (1==1)
#define false (!true)

#define SPI_CHAN 0
#define NUM_TIMES 100
@@ -78,7 +78,7 @@ int main (void)
printf ("| MHz | Size | mS/Trans | TpS | Mb/Sec | Latency mS |\n") ;
printf ("+-------+--------+----------+----------+-----------+------------+\n") ;

spiFail = FALSE ;
spiFail = false ;
spiSetup (speed * 1000000) ;
for (size = 1 ; size <= MAX_SIZE ; size *= 2)
{
@@ -89,7 +89,7 @@ int main (void)
if (wiringPiSPIDataRW (SPI_CHAN, myData, size) == -1)
{
printf ("SPI failure: %s\n", strerror (errno)) ;
spiFail = TRUE ;
spiFail = true ;
break ;
}
end = millis () ;


+ 1
- 1
gpio/Makefile View File

@@ -53,7 +53,7 @@ CC = arm-linux-gnueabihf-gcc
#DEBUG = -g -O0
DEBUG = -O2
INCLUDE = -I/$(LOCAL_INCLUDE_DIR)
CFLAGS = $(DEBUG) -Wall -Wextra $(INCLUDE) -Winline -pipe
CFLAGS = $(DEBUG) -Wall -Wextra -Werror $(INCLUDE) -Winline -pipe
LDFLAGS = -L/$(LOCAL_LIB_DIR)
LIBS = -lwiringPi -lwiringPiDev -lpthread -lrt -lm -lcrypt



+ 80
- 40
gpio/gpio.c View File

@@ -29,6 +29,7 @@
#include <ctype.h>
#include <string.h>
#include <unistd.h>
#include <error.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/types.h>
@@ -50,9 +51,9 @@ extern void doReadall (void) ;
extern void doAllReadall (void) ;
extern void doQmode (int argc, char *argv []) ;

#ifndef TRUE
# define TRUE (1==1)
# define FALSE (1==2)
#ifndef true
# define true (1==1)
# define false (1==2)
#endif

#define PI_USB_POWER_CONTROL 38
@@ -118,33 +119,41 @@ static int decodePin (const char *str)
*********************************************************************************
*/

static const char *searchPath [] =
{
"/sbin",
"/usr/sbin",
"/bin",
"/usr/bin",
NULL,
} ;

static char *findExecutable (const char *progName)
{
static const char *searchPath [] =
{
"/sbin",
"/usr/sbin",
"/bin",
"/usr/bin",
NULL,
} ;

static char *path = NULL ;
int len = strlen (progName) ;
int i = 0 ;
size_t len = strlen (progName) ;
unsigned int i = 0 ;
struct stat statBuf ;

for (i = 0 ; searchPath [i] != NULL ; ++i)
{
path = malloc (strlen (searchPath [i]) + len + 2) ;
if( (path = malloc (strlen (searchPath [i]) + len + 2)) == NULL )
{
error( EXIT_FAILURE, 0, "Insufficient memory\n" );
}
sprintf (path, "%s/%s", searchPath [i], progName) ;

if (stat (path, &statBuf) == 0)
return path ;
{
break;
}

free (path) ;
path = NULL;
}

return NULL ;
return path;
}


@@ -181,7 +190,7 @@ static void changeOwner (char *cmd, char *file)
static int moduleLoaded (char *modName)
{
int len = strlen (modName) ;
int found = FALSE ;
int found = false ;
FILE *fd = fopen ("/proc/modules", "r") ;
char line [80] ;

@@ -196,7 +205,7 @@ static int moduleLoaded (char *modName)
if (strncmp (line, modName, len) != 0)
continue ;

found = TRUE ;
found = true ;
break ;
}

@@ -234,7 +243,7 @@ static void _doLoadUsage (char *argv [])

static void doLoad (int argc, char *argv [])
{
char *module1, *module2 ;
char *module1, *module2, *loader_path ;
char cmd [80] ;
char *file1, *file2 ;
char args1 [32], args2 [32] ;
@@ -274,19 +283,27 @@ static void doLoad (int argc, char *argv [])
else
_doLoadUsage (argv) ;

if (findExecutable ("modprobe") == NULL)
printf ("No found\n") ;
if ((loader_path = findExecutable (MODPROBE)) == NULL)
{
error( EXIT_FAILURE, 0, "\"%s\" not found, unable to load module\n", loader_path );
}

if (!moduleLoaded (module1))
{
sprintf (cmd, "%s %s%s", findExecutable (MODPROBE), module1, args1) ;
system (cmd) ;
sprintf (cmd, "%s %s%s", loader_path, module1, args1) ;
if( system(cmd) == -1 )
{
error( EXIT_FAILURE, 0, "Can't execute %s", cmd);
}
}

if (!moduleLoaded (module2))
{
sprintf (cmd, "%s %s%s", findExecutable (MODPROBE), module2, args2) ;
system (cmd) ;
sprintf (cmd, "%s %s%s", loader_path, module2, args2) ;
if( system(cmd) == -1 )
{
error( EXIT_FAILURE, 0, "Can't execute %s", cmd);
}
}

if (!moduleLoaded (module2))
@@ -295,6 +312,9 @@ static void doLoad (int argc, char *argv [])
exit (1) ;
}


free( loader_path );

sleep (1) ; // To let things get settled

changeOwner (argv [0], file1) ;
@@ -316,7 +336,7 @@ static void _doUnLoadUsage (char *argv [])

static void doUnLoad (int argc, char *argv [])
{
char *module1, *module2 ;
char *module1, *module2, *unloader_path ;
char cmd [80] ;

checkDevTree (argv) ;
@@ -335,18 +355,35 @@ static void doUnLoad (int argc, char *argv [])
module2 = "i2c_bcm2708" ;
}
else
{
_doUnLoadUsage (argv) ;
}

if (moduleLoaded (module1))
if ((unloader_path = findExecutable (RMMOD)) == NULL)
{
sprintf (cmd, "%s %s", findExecutable (RMMOD), module1) ;
system (cmd) ;
error( 0, 0, "\"%s\" not found, unable to unload modules\n", unloader_path );
}

if (moduleLoaded (module2))
else
{
sprintf (cmd, "%s %s", findExecutable (RMMOD), module2) ;
system (cmd) ;
if (moduleLoaded (module1))
{
sprintf (cmd, "%s %s", unloader_path, module1) ;
if( system(cmd) == -1 )
{
error( 0, 0, "Can't execute %s", cmd);
}
}

if (moduleLoaded (module2))
{
sprintf (cmd, "%s %s", unloader_path, module2) ;
if( system(cmd) == -1 )
{
error( 0, 0, "Can't execute %s", cmd);
}
}

free( unloader_path );
}
}

@@ -1287,9 +1324,12 @@ static void doVersion (char *argv [])
{
if ((fd = fopen ("/proc/device-tree/model", "r")) != NULL)
{
fgets (name, 80, fd) ;
if( fgets (name, 80, fd) != NULL )
{
printf (" *--> %s\n", name) ;
}
fclose (fd) ;
printf (" *--> %s\n", name) ;
}
}

@@ -1313,7 +1353,7 @@ int main (int argc, char *argv [])
if (getenv ("WIRINGPI_DEBUG") != NULL)
{
printf ("gpio: wiringPi debug mode enabled\n") ;
wiringPiDebug = TRUE ;
wiringPiDebug = true ;
}

if (argc == 1)
@@ -1475,7 +1515,7 @@ int main (int argc, char *argv [])
exit (EXIT_FAILURE) ;
}

if (!loadWPiExtension (argv [0], argv [2], TRUE))
if (!loadWPiExtension (argv [0], argv [2], true))
{
fprintf (stderr, "%s: Extension load failed: %s\n", argv [0], strerror (errno)) ;
exit (EXIT_FAILURE) ;
@@ -1524,8 +1564,8 @@ int main (int argc, char *argv [])
else if (strcasecmp (argv [1], "i2cd" ) == 0) doI2Cdetect (argc, argv) ;
else if (strcasecmp (argv [1], "reset" ) == 0) doReset (argv [0]) ;
else if (strcasecmp (argv [1], "wb" ) == 0) doWriteByte (argc, argv) ;
else if (strcasecmp (argv [1], "rbx" ) == 0) doReadByte (argc, argv, TRUE) ;
else if (strcasecmp (argv [1], "rbd" ) == 0) doReadByte (argc, argv, FALSE) ;
else if (strcasecmp (argv [1], "rbx" ) == 0) doReadByte (argc, argv, true) ;
else if (strcasecmp (argv [1], "rbd" ) == 0) doReadByte (argc, argv, false) ;
else if (strcasecmp (argv [1], "clock" ) == 0) doClock (argc, argv) ;
else if (strcasecmp (argv [1], "wfi" ) == 0) doWfi (argc, argv) ;
else


+ 3
- 3
gpio/readall.c View File

@@ -37,9 +37,9 @@

extern int wpMode ;

#ifndef TRUE
# define TRUE (1==1)
# define FALSE (1==2)
#ifndef true
# define true (1==1)
# define false (1==2)
#endif

/*


+ 1
- 1
wiringPi/Makefile View File

@@ -54,7 +54,7 @@ CC = arm-linux-gnueabihf-gcc
DEBUG = -O2
INCLUDE = -I.
DEFS = -D_GNU_SOURCE
CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Wextra -Winline $(INCLUDE) -pipe -fPIC
CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Wextra -Winline -Werror $(INCLUDE) -pipe -fPIC
#CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Wextra -Wconversion -Winline $(INCLUDE) -pipe -fPIC
LIBS = -lm -lpthread -lrt -lcrypt



+ 2
- 2
wiringPi/ads1115.c View File

@@ -278,7 +278,7 @@ int ads1115Setup (const int pinBase, int i2cAddr)
int fd ;

if ((fd = wiringPiI2CSetup (i2cAddr)) < 0)
return FALSE ;
return false ;

node = wiringPiNewNode (pinBase, 8) ;

@@ -289,5 +289,5 @@ int ads1115Setup (const int pinBase, int i2cAddr)
node->analogWrite = myAnalogWrite ;
node->digitalWrite = myDigitalWrite ;

return TRUE ;
return true ;
}

+ 2
- 2
wiringPi/bmp180.c View File

@@ -192,7 +192,7 @@ int bmp180Setup (const int pinBase)
struct wiringPiNodeStruct *node ;

if ((fd = wiringPiI2CSetup (I2C_ADDRESS)) < 0)
return FALSE ;
return false ;

node = wiringPiNewNode (pinBase, 4) ;

@@ -233,5 +233,5 @@ int bmp180Setup (const int pinBase)
p1 = 1.0 - 7357.0 * pow (2.0, -20.0) ;
p2 = 3038.0 * 100.0 * pow (2.0, -36.0) ;

return TRUE ;
return true ;
}

+ 36
- 22
wiringPi/drcNet.c View File

@@ -32,6 +32,7 @@
#include <string.h>
#include <errno.h>
#include <crypt.h>
#include <stdlib.h>


#include "wiringPi.h"
@@ -103,31 +104,44 @@ static char *getChallenge (int fd)
static int authenticate (int fd, const char *pass)
{
char *challenge ;
char *encrypted ;
char salted [1024] ;

if ((challenge = getChallenge (fd)) == NULL)
return -1 ;
int return_value = -1;

sprintf (salted, "$6$%s$", challenge) ;
encrypted = crypt (pass, salted) ;
// This is an assertion, or sanity check on my part...
// The '20' comes from the $6$ then the 16 characters of the salt,
// then the terminating $.

if (strncmp (encrypted, salted, 20) != 0)
if ((challenge = getChallenge (fd)) != NULL)
{
errno = EBADE ;
return -1 ;
}
char *salted ;

// 86 characters is the length of the SHA-256 hash
if( asprintf(&salted, "$6$%s$", challenge) >=0 )
{
char *encrypted ;

if (write (fd, encrypted + 20, 86) == 86)
return 0 ;
else
return -1 ;
encrypted = crypt (pass, salted) ;

// This is an assertion, or sanity check on my part...
// The '20' comes from the $6$ then the 16 characters of the salt,
// then the terminating $.

if (strncmp (encrypted, salted, 20) == 0)
{

// 86 characters is the length of the SHA-256 hash

if (write (fd, encrypted + 20, 86) == 86)
{
return_value = 0 ;
}
}
else
{
errno = EBADE ;
}

free( salted );
}
}
return return_value ;
}


@@ -380,12 +394,12 @@ int drcSetupNet (const int pinBase, const int numPins, const char *ipAddress, co
struct wiringPiNodeStruct *node ;

if ((fd = _drcSetupNet (ipAddress, port, password)) < 0)
return FALSE ;
return false ;

len = sizeof (struct drcNetComStruct) ;

if (setsockopt (fd, SOL_SOCKET, SO_RCVLOWAT, (void *)&len, sizeof (len)) < 0)
return FALSE ;
return false ;

node = wiringPiNewNode (pinBase, numPins) ;

@@ -401,5 +415,5 @@ int drcSetupNet (const int pinBase, const int numPins, const char *ipAddress, co
//node->digitalWrite8 = myDigitalWrite8 ;
node->pwmWrite = myPwmWrite ;

return TRUE ;
return true ;
}

+ 5
- 5
wiringPi/drcSerial.c View File

@@ -151,7 +151,7 @@ int drcSetupSerial (const int pinBase, const int numPins, const char *device, co
struct wiringPiNodeStruct *node ;

if ((fd = serialOpen (device, baud)) < 0)
return FALSE ;
return false ;

delay (10) ; // May need longer if it's an Uno that reboots on the open...

@@ -160,7 +160,7 @@ int drcSetupSerial (const int pinBase, const int numPins, const char *device, co
while (serialDataAvail (fd))
(void)serialGetchar (fd) ;

ok = FALSE ;
ok = false ;
for (tries = 1 ; (tries < 5) && (!ok) ; ++tries)
{
serialPutchar (fd, '@') ; // Ping
@@ -170,7 +170,7 @@ int drcSetupSerial (const int pinBase, const int numPins, const char *device, co
{
if (serialGetchar (fd) == '@')
{
ok = TRUE ;
ok = true ;
break ;
}
}
@@ -179,7 +179,7 @@ int drcSetupSerial (const int pinBase, const int numPins, const char *device, co
if (!ok)
{
serialClose (fd) ;
return FALSE ;
return false ;
}

node = wiringPiNewNode (pinBase, numPins) ;
@@ -192,5 +192,5 @@ int drcSetupSerial (const int pinBase, const int numPins, const char *device, co
node->digitalWrite = myDigitalWrite ;
node->pwmWrite = myPwmWrite ;

return TRUE ;
return true ;
}

+ 3
- 3
wiringPi/ds18b20.c View File

@@ -123,7 +123,7 @@ int ds18b20Setup (const int pinBase, const char *deviceId)
// Allocate space for the filename

if ((fileName = malloc (strlen (W1_PREFIX) + strlen (W1_POSTFIX) + strlen (deviceId) + 1)) == NULL)
return FALSE ;
return false ;

sprintf (fileName, "%s%s%s", W1_PREFIX, deviceId, W1_POSTFIX) ;

@@ -132,7 +132,7 @@ int ds18b20Setup (const int pinBase, const char *deviceId)
free (fileName) ;

if (fd < 0)
return FALSE ;
return false ;

// We'll keep the file open, to make access a little faster
// although it's very slow reading these things anyway )-:
@@ -142,5 +142,5 @@ int ds18b20Setup (const int pinBase, const char *deviceId)
node->fd = fd ;
node->analogRead = myAnalogRead ;

return TRUE ;
return true ;
}

+ 4
- 4
wiringPi/htu21d.c View File

@@ -40,7 +40,7 @@

int checksum (UNU uint8_t data [4])
{
return TRUE ;
return true ;
}


@@ -127,7 +127,7 @@ int htu21dSetup (const int pinBase)
int status ;

if ((fd = wiringPiI2CSetup (I2C_ADDRESS)) < 0)
return FALSE ;
return false ;

node = wiringPiNewNode (pinBase, 2) ;

@@ -138,7 +138,7 @@ int htu21dSetup (const int pinBase)

data = 0xFE ;
if (write (fd, &data, 1) != 1)
return FALSE ;
return false ;

delay (15) ;

@@ -146,5 +146,5 @@ int htu21dSetup (const int pinBase)

status = wiringPiI2CReadReg8 (fd, 0xE7) ;

return (status == 0x02) ? TRUE : FALSE ;
return (status == 0x02) ? true : false ;
}

+ 2
- 2
wiringPi/max31855.c View File

@@ -88,12 +88,12 @@ int max31855Setup (const int pinBase, int spiChannel)
struct wiringPiNodeStruct *node ;

if (wiringPiSPISetup (spiChannel, 5000000) < 0) // 5MHz - prob 4 on the Pi
return FALSE ;
return false ;

node = wiringPiNewNode (pinBase, 4) ;

node->fd = spiChannel ;
node->analogRead = myAnalogRead ;

return TRUE ;
return true ;
}

+ 2
- 2
wiringPi/max5322.c View File

@@ -66,7 +66,7 @@ int max5322Setup (const int pinBase, int spiChannel)
unsigned char spiData [2] ;

if (wiringPiSPISetup (spiChannel, 8000000) < 0) // 10MHz Max
return FALSE ;
return false ;

node = wiringPiNewNode (pinBase, 2) ;

@@ -80,5 +80,5 @@ int max5322Setup (const int pinBase, int spiChannel)
wiringPiSPIDataRW (node->fd, spiData, 2) ;

return TRUE ;
return true ;
}

+ 2
- 2
wiringPi/mcp23008.c View File

@@ -132,7 +132,7 @@ int mcp23008Setup (const int pinBase, const int i2cAddress)
struct wiringPiNodeStruct *node ;

if ((fd = wiringPiI2CSetup (i2cAddress)) < 0)
return FALSE ;
return false ;

wiringPiI2CWriteReg8 (fd, MCP23x08_IOCON, IOCON_INIT) ;

@@ -145,5 +145,5 @@ int mcp23008Setup (const int pinBase, const int i2cAddress)
node->digitalWrite = myDigitalWrite ;
node->data2 = wiringPiI2CReadReg8 (fd, MCP23x08_OLAT) ;

return TRUE ;
return true ;
}

+ 2
- 2
wiringPi/mcp23016.c View File

@@ -146,7 +146,7 @@ int mcp23016Setup (const int pinBase, const int i2cAddress)
struct wiringPiNodeStruct *node ;

if ((fd = wiringPiI2CSetup (i2cAddress)) < 0)
return FALSE ;
return false ;

wiringPiI2CWriteReg8 (fd, MCP23016_IOCON0, IOCON_INIT) ;
wiringPiI2CWriteReg8 (fd, MCP23016_IOCON1, IOCON_INIT) ;
@@ -160,5 +160,5 @@ int mcp23016Setup (const int pinBase, const int i2cAddress)
node->data2 = wiringPiI2CReadReg8 (fd, MCP23016_OLAT0) ;
node->data3 = wiringPiI2CReadReg8 (fd, MCP23016_OLAT1) ;

return TRUE ;
return true ;
}

+ 2
- 2
wiringPi/mcp23017.c View File

@@ -177,7 +177,7 @@ int mcp23017Setup (const int pinBase, const int i2cAddress)
struct wiringPiNodeStruct *node ;

if ((fd = wiringPiI2CSetup (i2cAddress)) < 0)
return FALSE ;
return false ;

wiringPiI2CWriteReg8 (fd, MCP23x17_IOCON, IOCON_INIT) ;

@@ -191,5 +191,5 @@ int mcp23017Setup (const int pinBase, const int i2cAddress)
node->data2 = wiringPiI2CReadReg8 (fd, MCP23x17_OLATA) ;
node->data3 = wiringPiI2CReadReg8 (fd, MCP23x17_OLATB) ;

return TRUE ;
return true ;
}

+ 2
- 2
wiringPi/mcp23s08.c View File

@@ -170,7 +170,7 @@ int mcp23s08Setup (const int pinBase, const int spiPort, const int devId)
struct wiringPiNodeStruct *node ;

if (wiringPiSPISetup (spiPort, MCP_SPEED) < 0)
return FALSE ;
return false ;

writeByte (spiPort, devId, MCP23x08_IOCON, IOCON_INIT) ;

@@ -184,5 +184,5 @@ int mcp23s08Setup (const int pinBase, const int spiPort, const int devId)
node->digitalWrite = myDigitalWrite ;
node->data2 = readByte (spiPort, devId, MCP23x08_OLAT) ;

return TRUE ;
return true ;
}

+ 2
- 2
wiringPi/mcp23s17.c View File

@@ -215,7 +215,7 @@ int mcp23s17Setup (const int pinBase, const int spiPort, const int devId)
struct wiringPiNodeStruct *node ;

if (wiringPiSPISetup (spiPort, MCP_SPEED) < 0)
return FALSE ;
return false ;

writeByte (spiPort, devId, MCP23x17_IOCON, IOCON_INIT | IOCON_HAEN) ;
writeByte (spiPort, devId, MCP23x17_IOCONB, IOCON_INIT | IOCON_HAEN) ;
@@ -231,5 +231,5 @@ int mcp23s17Setup (const int pinBase, const int spiPort, const int devId)
node->data2 = readByte (spiPort, devId, MCP23x17_OLATA) ;
node->data3 = readByte (spiPort, devId, MCP23x17_OLATB) ;

return TRUE ;
return true ;
}

+ 2
- 2
wiringPi/mcp3002.c View File

@@ -65,12 +65,12 @@ int mcp3002Setup (const int pinBase, int spiChannel)
struct wiringPiNodeStruct *node ;

if (wiringPiSPISetup (spiChannel, 1000000) < 0)
return FALSE ;
return false ;

node = wiringPiNewNode (pinBase, 2) ;

node->fd = spiChannel ;
node->analogRead = myAnalogRead ;

return TRUE ;
return true ;
}

+ 2
- 2
wiringPi/mcp3004.c View File

@@ -65,12 +65,12 @@ int mcp3004Setup (const int pinBase, int spiChannel)
struct wiringPiNodeStruct *node ;

if (wiringPiSPISetup (spiChannel, 1000000) < 0)
return FALSE ;
return false ;

node = wiringPiNewNode (pinBase, 8) ;

node->fd = spiChannel ;
node->analogRead = myAnalogRead ;

return TRUE ;
return true ;
}

+ 25
- 5
wiringPi/mcp3422.c View File

@@ -29,10 +29,13 @@
#include <unistd.h>
#include <stdint.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <sys/ioctl.h>

#include <wiringPi.h>
#include <wiringPiI2C.h>
#include "wiring_private.h"

#include "mcp3422.h"

@@ -45,12 +48,25 @@

void waitForConversion (int fd, unsigned char *buffer, int n)
{
for (;;)
enum { MAX_CONVERSION_WAIT = 400 }; // Slowest conversion @ 3.75 samples/second = 266.7ms, x 1.5 "fudge factor"

for( uint16_t conversion_time_ms=0; conversion_time_ms<MAX_CONVERSION_WAIT; conversion_time_ms++ )
{
read (fd, buffer, n) ;
ssize_t num_bytes_read;

num_bytes_read = pread( fd, buffer, n, 0 );

if( (num_bytes_read == IO_FAIL) && (errno != EINTR) && (errno != EAGAIN) )
{
wiringPiFailure( WPI_ALMOST, "mcp3422:waitForConversion: %s\n", strerror(errno) );
}

if ((buffer [n-1] & 0x80) == 0)
{
break ;
delay (1) ;
}

delay (1) ; // Milliseconds
}
}

@@ -94,6 +110,10 @@ int myAnalogRead (struct wiringPiNodeStruct *node, int chan)
waitForConversion (node->fd, buffer, 3) ;
value = ((buffer [0] & 0x0F) << 8) | buffer [1] ;
break ;

default:
wiringPiFailure( WPI_ALMOST, "mcp3422:myAnalogRead: unhandled sample rate value %u", node->data0 );
break;
}

return value ;
@@ -112,7 +132,7 @@ int mcp3422Setup (int pinBase, int i2cAddress, int sampleRate, int gain)
struct wiringPiNodeStruct *node ;

if ((fd = wiringPiI2CSetup (i2cAddress)) < 0)
return FALSE ;
return false ;

node = wiringPiNewNode (pinBase, 4) ;

@@ -121,5 +141,5 @@ int mcp3422Setup (int pinBase, int i2cAddress, int sampleRate, int gain)
node->data1 = gain ;
node->analogRead = myAnalogRead ;

return TRUE ;
return true ;
}

+ 2
- 2
wiringPi/mcp4802.c View File

@@ -65,12 +65,12 @@ int mcp4802Setup (const int pinBase, int spiChannel)
struct wiringPiNodeStruct *node ;

if (wiringPiSPISetup (spiChannel, 1000000) < 0)
return FALSE ;
return false ;

node = wiringPiNewNode (pinBase, 2) ;

node->fd = spiChannel ;
node->analogWrite = myAnalogWrite ;

return TRUE ;
return true ;
}

+ 2
- 2
wiringPi/pcf8574.c View File

@@ -112,7 +112,7 @@ int pcf8574Setup (const int pinBase, const int i2cAddress)
struct wiringPiNodeStruct *node ;

if ((fd = wiringPiI2CSetup (i2cAddress)) < 0)
return FALSE ;
return false ;

node = wiringPiNewNode (pinBase, 8) ;

@@ -122,5 +122,5 @@ int pcf8574Setup (const int pinBase, const int i2cAddress)
node->digitalWrite = myDigitalWrite ;
node->data2 = wiringPiI2CRead (fd) ;

return TRUE ;
return true ;
}

+ 19
- 6
wiringPi/pcf8591.c View File

@@ -24,9 +24,12 @@
*/

#include <unistd.h>
#include <errno.h>
#include <string.h>

#include "wiringPi.h"
#include "wiringPiI2C.h"
#include "wiring_private.h"

#include "pcf8591.h"

@@ -38,10 +41,20 @@

static void myAnalogWrite (struct wiringPiNodeStruct *node, UNU int pin, int value)
{
unsigned char b [2] ;
b [0] = 0x40 ;
b [1] = value & 0xFF ;
write (node->fd, b, 2) ;
unsigned char b[] = { 0x40, (value & 0xFF) };
ssize_t num_bytes_to_send = (ssize_t)sizeof( b );
ssize_t num_bytes_sent;

num_bytes_sent = TEMP_FAILURE_RETRY( write(node->fd, b, num_bytes_to_send) );

if( num_bytes_sent == IO_FAIL )
{
wiringPiFailure( WPI_ALMOST, "pcf8591:myAnalogWrite: %s\n", strerror(errno) );
}
else if( num_bytes_sent != num_bytes_to_send )
{
wiringPiFailure( WPI_ALMOST, "pcf8591:myAnalogWrite: sent %d bytes instead of %d", num_bytes_sent, num_bytes_to_send );
}
}


@@ -78,7 +91,7 @@ int pcf8591Setup (const int pinBase, const int i2cAddress)
struct wiringPiNodeStruct *node ;

if ((fd = wiringPiI2CSetup (i2cAddress)) < 0)
return FALSE ;
return false ;

node = wiringPiNewNode (pinBase, 4) ;

@@ -86,5 +99,5 @@ int pcf8591Setup (const int pinBase, const int i2cAddress)
node->analogRead = myAnalogRead ;
node->analogWrite = myAnalogWrite ;

return TRUE ;
return true ;
}

+ 3
- 3
wiringPi/pseudoPins.c View File

@@ -79,10 +79,10 @@ int pseudoPinsSetup (const int pinBase)
node->fd = shm_open (SHARED_NAME, O_CREAT | O_RDWR, 0666) ;

if (node->fd < 0)
return FALSE ;
return false ;

if (ftruncate (node->fd, PSEUDO_PINS * sizeof (int)) < 0)
return FALSE ;
return false ;

ptr = mmap (NULL, PSEUDO_PINS * sizeof (int), PROT_READ | PROT_WRITE, MAP_SHARED, node->fd, 0) ;

@@ -91,5 +91,5 @@ int pseudoPinsSetup (const int pinBase)
node->analogRead = myAnalogRead ;
node->analogWrite = myAnalogWrite ;

return TRUE ;
return true ;
}

+ 11
- 11
wiringPi/rht03.c View File

@@ -51,7 +51,7 @@ static int maxDetectLowHighWait (const int pin)
{
gettimeofday (&now, NULL) ;
if (timercmp (&now, &timeUp, >))
return FALSE ;
return false ;
}

// Wait for it to go HIGH
@@ -65,10 +65,10 @@ static int maxDetectLowHighWait (const int pin)
{
gettimeofday (&now, NULL) ;
if (timercmp (&now, &timeUp, >))
return FALSE ;
return false ;
}

return TRUE ;
return true ;
}


@@ -103,7 +103,7 @@ static unsigned int maxDetectClockByte (const int pin)
/*
* maxDetectRead:
* Read in and return the 4 data bytes from the MaxDetect sensor.
* Return TRUE/FALSE depending on the checksum validity
* Return true/false depending on the checksum validity
*********************************************************************************
*/

@@ -129,7 +129,7 @@ static int maxDetectRead (const int pin, unsigned char buffer [4])
// Now wait for sensor to pull pin low

if (!maxDetectLowHighWait (pin))
return FALSE ;
return false ;

// and read in 5 bytes (40 bits)

@@ -158,7 +158,7 @@ static int maxDetectRead (const int pin, unsigned char buffer [4])
// reading is probably bogus.

if ((took.tv_sec != 0) || (took.tv_usec > 16000))
return FALSE ;
return false ;

return checksum == localBuf [4] ;
}
@@ -181,7 +181,7 @@ static int myReadRHT03 (const int pin, int *temp, int *rh)
result = maxDetectRead (pin, buffer) ;

if (!result)
return FALSE ;
return false ;

*rh = (buffer [0] * 256 + buffer [1]) ;
*temp = (buffer [2] * 256 + buffer [3]) ;
@@ -196,9 +196,9 @@ static int myReadRHT03 (const int pin, int *temp, int *rh)
// (which does seem to happen - no realtime here)

if ((*rh > 999) || (*temp > 800) || (*temp < -400))
return FALSE ;
return false ;

return TRUE ;
return true ;
}


@@ -239,7 +239,7 @@ int rht03Setup (const int pinBase, const int piPin)
struct wiringPiNodeStruct *node ;

if ((piPin & PI_GPIO_MASK) != 0) // Must be an on-board pin
return FALSE ;
return false ;
// 2 pins - temperature and humidity

@@ -248,5 +248,5 @@ int rht03Setup (const int pinBase, const int piPin)
node->fd = piPin ;
node->analogRead = myAnalogRead ;

return TRUE ;
return true ;
}

+ 2
- 2
wiringPi/sn3218.c View File

@@ -55,7 +55,7 @@ int sn3218Setup (const int pinBase)
struct wiringPiNodeStruct *node ;

if ((fd = wiringPiI2CSetup (0x54)) < 0)
return FALSE ;
return false ;

// Setup the chip - initialise all 18 LEDs to off

@@ -71,5 +71,5 @@ int sn3218Setup (const int pinBase)
node->fd = fd ;
node->analogWrite = myAnalogWrite ;

return TRUE ;
return true ;
}

+ 1
- 1
wiringPi/sr595.c View File

@@ -105,5 +105,5 @@ int sr595Setup (const int pinBase, const int numPins,
pinMode (clockPin, OUTPUT) ;
pinMode (latchPin, OUTPUT) ;

return TRUE ;
return true ;
}

+ 139
- 66
wiringPi/wiringPi.c View File

@@ -76,6 +76,8 @@

#include "wiringPi.h"
#include "../version.h"
#include "wiring_private.h"


// Environment Variables

@@ -139,8 +141,8 @@ static volatile unsigned int GPIO_PWM ;
#define PAGE_SIZE (4*1024)
#define BLOCK_SIZE (4*1024)

static unsigned int usingGpioMem = FALSE ;
static int wiringPiSetuped = FALSE ;
static unsigned int usingGpioMem = false ;
static int wiringPiSetuped = false ;

// PWM
// Word offsets into the PWM control region
@@ -302,12 +304,12 @@ static pthread_mutex_t pinMutex ;

// Debugging & Return codes

int wiringPiDebug = FALSE ;
int wiringPiReturnCodes = FALSE ;
int wiringPiDebug = false ;
int wiringPiReturnCodes = false ;

// Use /dev/gpiomem ?

int wiringPiTryGpioMem = FALSE ;
int wiringPiTryGpioMem = false ;

// sysFds:
// Map a file descriptor from the /sys/class/gpio/gpioX/value
@@ -642,13 +644,16 @@ static uint8_t gpioToClkDiv [] =
*********************************************************************************
*/

int wiringPiFailure (int fatal, const char *message, ...)
//int wiringPiFailure (int fatal, const char *message, ...)
int wiringPiFailure (wpi_fail_t is_fatal, const char *message, ...)
{
va_list argp ;
char buffer [1024] ;

if (!fatal && wiringPiReturnCodes)
if( (is_fatal != WPI_FATAL) && (wiringPiReturnCodes == true) )
{
return -1 ;
}

va_start (argp, message) ;
vsnprintf (buffer, 1023, message, argp) ;
@@ -1305,14 +1310,19 @@ struct wiringPiNodeStruct *wiringPiFindNode (int pin)

static void pinModeDummy (UNU struct wiringPiNodeStruct *node, UNU int pin, UNU int mode) { return ; }
static void pullUpDnControlDummy (UNU struct wiringPiNodeStruct *node, UNU int pin, UNU int pud) { return ; }

#if defined (DUMMY_8)
static unsigned int digitalRead8Dummy (UNU struct wiringPiNodeStruct *node, UNU int UNU pin) { return 0 ; }
static void digitalWrite8Dummy (UNU struct wiringPiNodeStruct *node, UNU int pin, UNU int value) { return ; }
#endif

static int digitalReadDummy (UNU struct wiringPiNodeStruct *node, UNU int UNU pin) { return LOW ; }
static void digitalWriteDummy (UNU struct wiringPiNodeStruct *node, UNU int pin, UNU int value) { return ; }
static void pwmWriteDummy (UNU struct wiringPiNodeStruct *node, UNU int pin, UNU int value) { return ; }
static int analogReadDummy (UNU struct wiringPiNodeStruct *node, UNU int pin) { return 0 ; }
static void analogWriteDummy (UNU struct wiringPiNodeStruct *node, UNU int pin, UNU int value) { return ; }


struct wiringPiNodeStruct *wiringPiNewNode (int pinBase, int numPins)
{
int pin ;
@@ -1338,9 +1348,13 @@ struct wiringPiNodeStruct *wiringPiNewNode (int pinBase, int numPins)
node->pinMode = pinModeDummy ;
node->pullUpDnControl = pullUpDnControlDummy ;
node->digitalRead = digitalReadDummy ;
//node->digitalRead8 = digitalRead8Dummy ;
#if defined (DUMMY_8)
node->digitalRead8 = digitalRead8Dummy ;
#endif
node->digitalWrite = digitalWriteDummy ;
//node->digitalWrite8 = digitalWrite8Dummy ;
#if defined (DUMMY_8)
node->digitalWrite8 = digitalWrite8Dummy ;
#endif
node->pwmWrite = pwmWriteDummy ;
node->analogRead = analogReadDummy ;
node->analogWrite = analogWriteDummy ;
@@ -1505,7 +1519,7 @@ void pullUpDnControl (int pin, int pud)
return ;

*(gpio + GPPUD) = pud & 3 ; delayMicroseconds (5) ;
*(gpio + gpioToPUDCLK [pin]) = 1 << (pin & 31) ; delayMicroseconds (5) ;
*(gpio + gpioToPUDCLK [pin]) = GPIO_PIN_N_REGISTER_MASK( pin ) ; delayMicroseconds (5) ;
*(gpio + GPPUD) = 0 ; delayMicroseconds (5) ;
*(gpio + gpioToPUDCLK [pin]) = 0 ; delayMicroseconds (5) ;
@@ -1527,38 +1541,63 @@ void pullUpDnControl (int pin, int pud)

int digitalRead (int pin)
{
char c ;
struct wiringPiNodeStruct *node = wiringPiNodes ;
int pin_value = LOW;

if ((pin & PI_GPIO_MASK) == 0) // On-Board Pin
{
/**/ if (wiringPiMode == WPI_MODE_GPIO_SYS) // Sys mode
if( wiringPiMode == WPI_MODE_GPIO_SYS ) // Sys mode
{
if (sysFds [pin] == -1)
return LOW ;

lseek (sysFds [pin], 0L, SEEK_SET) ;
read (sysFds [pin], &c, 1) ;
return (c == '0') ? LOW : HIGH ;
if (sysFds [pin] != -1)
{
uint8_t pin_value_char = '0';
ssize_t num_bytes_read;

num_bytes_read = pread( sysFds [pin], &pin_value_char, 1, 0 );

if( num_bytes_read == IO_FAIL )
{
wiringPiFailure( WPI_ALMOST, "digitalRead: %s\n", strerror(errno) );
}
else if( num_bytes_read > 1 )
{
wiringPiFailure( WPI_FATAL, "digitalRead: read %d bytes instead of 1", num_bytes_read );
}

pin_value = (pin_value_char == '0') ? LOW : HIGH ;
}
}
else if (wiringPiMode == WPI_MODE_PINS)
pin = pinToGpio [pin] ;
else if (wiringPiMode == WPI_MODE_PHYS)
pin = physToGpio [pin] ;
else if (wiringPiMode != WPI_MODE_GPIO)
return LOW ;
else if( (wiringPiMode == WPI_MODE_PINS) || (wiringPiMode == WPI_MODE_PHYS) || (wiringPiMode == WPI_MODE_GPIO) )
{
if( wiringPiMode == WPI_MODE_PINS )
{
pin = pinToGpio [pin] ; // Translate wiringPi pin number to GPIO pin number
}
else if( wiringPiMode == WPI_MODE_PHYS ) // Translate physical pin number to GPIO number
{
pin = physToGpio [pin] ;
}

if ((*(gpio + gpioToGPLEV [pin]) & (1 << (pin & 31))) != 0)
return HIGH ;
else
return LOW ;
if( (*(gpio + gpioToGPLEV [pin]) & GPIO_PIN_N_REGISTER_MASK(pin)) != 0 )
{
pin_value = HIGH ;
}
else
{
pin_value = LOW ;
}
}
}
else
else // "Off-board" pin
{
if ((node = wiringPiFindNode (pin)) == NULL)
return LOW ;
return node->digitalRead (node, pin) ;
struct wiringPiNodeStruct *node = wiringPiNodes ;

if( (node = wiringPiFindNode (pin)) != NULL )
{
pin_value = node->digitalRead (node, pin) ;
}
}

return pin_value;
}


@@ -1599,26 +1638,51 @@ void digitalWrite (int pin, int value)
{
if (sysFds [pin] != -1)
{
if (value == LOW)
write (sysFds [pin], "0\n", 2) ;
else
write (sysFds [pin], "1\n", 2) ;
char *val_string;

if (value == LOW)
{
val_string = "0\n";
}
else
{
val_string = "1\n";
}

// Write value string to device file, excluding terminating NULL
ssize_t num_bytes_sent;
ssize_t num_bytes_to_send = (ssize_t)(sizeof(val_string) - sizeof(char));

num_bytes_sent = TEMP_FAILURE_RETRY( write(sysFds [pin], val_string, num_bytes_to_send) );

if( num_bytes_sent == IO_FAIL )
{
wiringPiFailure( WPI_ALMOST, "digitalWrite: %s\n", strerror(errno) );
}
else if( num_bytes_sent != num_bytes_to_send )
{
wiringPiFailure( WPI_ALMOST, "digitalWrite: sent %d bytes instead of %d", num_bytes_sent, num_bytes_to_send );
}
}
} // end if Sys mode
else if( (wiringPiMode == WPI_MODE_PINS) || (wiringPiMode == WPI_MODE_PHYS) || (wiringPiMode == WPI_MODE_GPIO) ) // On-board, not Sys mode
{
if (wiringPiMode == WPI_MODE_PINS)
{
pin = pinToGpio [pin] ;
}
else if (wiringPiMode == WPI_MODE_PHYS)
{
pin = physToGpio [pin] ;
}
return ;
}
else if (wiringPiMode == WPI_MODE_PINS)
pin = pinToGpio [pin] ;
else if (wiringPiMode == WPI_MODE_PHYS)
pin = physToGpio [pin] ;
else if (wiringPiMode != WPI_MODE_GPIO)
return ;

if (value == LOW)
*(gpio + gpioToGPCLR [pin]) = 1 << (pin & 31) ;
else
*(gpio + gpioToGPSET [pin]) = 1 << (pin & 31) ;
}
else
if (value == LOW)
*(gpio + gpioToGPCLR [pin]) = GPIO_PIN_N_REGISTER_MASK( pin ) ;
else
*(gpio + gpioToGPSET [pin]) = GPIO_PIN_N_REGISTER_MASK( pin ) ;
} // end if not Sys mode
} // end if On-board pin
else // "Off-board" pin
{
if ((node = wiringPiFindNode (pin)) != NULL)
node->digitalWrite (node, pin, value) ;
@@ -1880,9 +1944,7 @@ unsigned int digitalReadByte2 (void)

int waitForInterrupt (int pin, int mS)
{
int fd, x ;
uint8_t c ;
struct pollfd polls ;
int fd, x = 0 ;

/**/ if (wiringPiMode == WPI_MODE_PINS)
pin = pinToGpio [pin] ;
@@ -1890,9 +1952,10 @@ int waitForInterrupt (int pin, int mS)
pin = physToGpio [pin] ;

if ((fd = sysFds [pin]) == -1)
return -2 ;
return PIN_NOT_CONFIGURED ;

// Setup poll structure
struct pollfd polls ;

polls.fd = fd ;
polls.events = POLLPRI | POLLERR ;
@@ -1906,8 +1969,12 @@ int waitForInterrupt (int pin, int mS)

if (x > 0)
{
lseek (fd, 0, SEEK_SET) ; // Rewind
(void)read (fd, &c, 1) ; // Read & clear
uint8_t c ;

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-result"
pread( fd, &c, sizeof(c), 0 ); // If an error occurs, should result really be ignored?
#pragma GCC diagnostic pop
}

return x ;
@@ -1955,7 +2022,6 @@ int wiringPiISR (int pin, int mode, void (*function)(void))
char pinS [8] ;
pid_t pid ;
int count, i ;
char c ;
int bcmGpioPin ;

if ((pin < 0) || (pin > 63))
@@ -2023,7 +2089,14 @@ int wiringPiISR (int pin, int mode, void (*function)(void))

ioctl (sysFds [bcmGpioPin], FIONREAD, &count) ;
for (i = 0 ; i < count ; ++i)
read (sysFds [bcmGpioPin], &c, 1) ;
{
uint8_t c ;

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-result"
pread( sysFds [bcmGpioPin], &c, sizeof(c), 0 ); // If an error occurs, should result really be ignored?
#pragma GCC diagnostic pop
}

isrFunctions [pin] = function ;

@@ -2220,13 +2293,13 @@ int wiringPiSetup (void)
if (wiringPiSetuped)
return 0 ;

wiringPiSetuped = TRUE ;
wiringPiSetuped = true ;

if (getenv (ENV_DEBUG) != NULL)
wiringPiDebug = TRUE ;
wiringPiDebug = true ;

if (getenv (ENV_CODES) != NULL)
wiringPiReturnCodes = TRUE ;
wiringPiReturnCodes = true ;

if (wiringPiDebug)
printf ("wiringPi: wiringPiSetup called\n") ;
@@ -2281,7 +2354,7 @@ int wiringPiSetup (void)
if ((fd = open ("/dev/gpiomem", O_RDWR | O_SYNC | O_CLOEXEC) ) >= 0) // We're using gpiomem
{
piGpioBase = 0 ;
usingGpioMem = TRUE ;
usingGpioMem = true ;
}
else
return wiringPiFailure (WPI_ALMOST, "wiringPiSetup: Unable to open /dev/mem or /dev/gpiomem: %s.\n"
@@ -2413,13 +2486,13 @@ int wiringPiSetupSys (void)
if (wiringPiSetuped)
return 0 ;

wiringPiSetuped = TRUE ;
wiringPiSetuped = true ;

if (getenv (ENV_DEBUG) != NULL)
wiringPiDebug = TRUE ;
wiringPiDebug = true ;

if (getenv (ENV_CODES) != NULL)
wiringPiReturnCodes = TRUE ;
wiringPiReturnCodes = true ;

if (wiringPiDebug)
printf ("wiringPi: wiringPiSetupSys called\n") ;


+ 17
- 7
wiringPi/wiringPi.h View File

@@ -24,14 +24,18 @@
#ifndef __WIRING_PI_H__
#define __WIRING_PI_H__

/*
// C doesn't have true/false by default and I can never remember which
// way round they are, so ...
// (and yes, I know about stdbool.h but I like capitals for these and I'm old)

#ifndef TRUE
# define TRUE (1==1)
# define FALSE (!TRUE)
#endif
#ifndef true
# define true (1==1)
# define false (!true)
#endif
*/
#include <stdbool.h> // "True today, false tomorrow": C has boolean data types and "true"/"false" as of C11


// GCC warning suppressor

@@ -125,8 +129,14 @@ extern const int piMemorySize [ 8] ;

// Failure modes

#define WPI_FATAL (1==1)
#define WPI_ALMOST (1==2)
typedef enum {
WPI_ALMOST = 0,
WPI_FATAL = 1
} wpi_fail_t;
//#define WPI_FATAL (1==1)
//#define WPI_ALMOST (1==2)

enum { PIN_NOT_CONFIGURED = -2 };


// wiringPiNodeStruct:
@@ -185,7 +195,7 @@ extern "C" {

// Internal

extern int wiringPiFailure (int fatal, const char *message, ...) ;
extern int wiringPiFailure (wpi_fail_t fatal, const char *message, ...) ;

// Core wiringPi functions



+ 29
- 2
wiringPi/wiringSerial.c View File

@@ -28,11 +28,15 @@
#include <termios.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>

#include "wiringPi.h"
#include "wiringSerial.h"
#include "wiring_private.h"


/*
* serialOpen:
@@ -155,7 +159,18 @@ void serialClose (const int fd)

void serialPutchar (const int fd, const unsigned char c)
{
write (fd, &c, 1) ;
ssize_t num_bytes_sent;

num_bytes_sent = TEMP_FAILURE_RETRY( write(fd, &c, NUM_BYTES_PER_CHAR) );

if( num_bytes_sent == IO_FAIL )
{
wiringPiFailure( WPI_ALMOST, "serialPutchar: %s\n", strerror(errno) );
}
else if( num_bytes_sent != NUM_BYTES_PER_CHAR )
{
wiringPiFailure( WPI_ALMOST, "serialPutchar: sent %d bytes instead of %d", num_bytes_sent, NUM_BYTES_PER_CHAR );
}
}


@@ -167,7 +182,19 @@ void serialPutchar (const int fd, const unsigned char c)

void serialPuts (const int fd, const char *s)
{
write (fd, s, strlen (s)) ;
ssize_t num_char_to_send = (ssize_t)strlen( s );
ssize_t num_bytes_sent;

num_bytes_sent = TEMP_FAILURE_RETRY( write(fd, s, num_char_to_send) );

if( num_bytes_sent == IO_FAIL )
{
wiringPiFailure( WPI_ALMOST, "serialPuts: %s\n", strerror(errno) );
}
else if( num_bytes_sent != num_char_to_send )
{
wiringPiFailure( WPI_ALMOST, "serialPuts: sent %d bytes instead of %d", num_bytes_sent, num_char_to_send );
}
}

/*


+ 83
- 83
wiringPi/wpiExtensions.c View File

@@ -146,7 +146,7 @@ static char *extractInt (char *progName, char *p, int *num)
static char *extractStr (char *progName, char *p, char **str)
{
char *q, *r ;
int quoted = FALSE ;
int quoted = false ;

if (*p != ':')
{
@@ -158,7 +158,7 @@ static char *extractStr (char *progName, char *p, char **str)

if (*p == '[')
{
quoted = TRUE ;
quoted = true ;
++p ;
}

@@ -205,17 +205,17 @@ static int doExtensionMcp23008 (char *progName, int pinBase, char *params)
int i2c ;

if ((params = extractInt (progName, params, &i2c)) == NULL)
return FALSE ;
return false ;

if ((i2c < 0x01) || (i2c > 0x77))
{
verbError ("%s: i2c address (0x%X) out of range", progName, i2c) ;
return FALSE ;
return false ;
}

mcp23008Setup (pinBase, i2c) ;

return TRUE ;
return true ;
}


@@ -231,17 +231,17 @@ static int doExtensionMcp23016 (char *progName, int pinBase, char *params)
int i2c ;

if ((params = extractInt (progName, params, &i2c)) == NULL)
return FALSE ;
return false ;

if ((i2c < 0x03) || (i2c > 0x77))
{
verbError ("%s: i2c address (0x%X) out of range", progName, i2c) ;
return FALSE ;
return false ;
}

mcp23016Setup (pinBase, i2c) ;

return TRUE ;
return true ;
}


@@ -257,17 +257,17 @@ static int doExtensionMcp23017 (char *progName, int pinBase, char *params)
int i2c ;

if ((params = extractInt (progName, params, &i2c)) == NULL)
return FALSE ;
return false ;

if ((i2c < 0x03) || (i2c > 0x77))
{
verbError ("%s: i2c address (0x%X) out of range", progName, i2c) ;
return FALSE ;
return false ;
}

mcp23017Setup (pinBase, i2c) ;

return TRUE ;
return true ;
}


@@ -283,26 +283,26 @@ static int doExtensionMcp23s08 (char *progName, int pinBase, char *params)
int spi, port ;

if ((params = extractInt (progName, params, &spi)) == NULL)
return FALSE ;
return false ;

if ((spi < 0) || (spi > 1))
{
verbError ("%s: SPI address (%d) out of range", progName, spi) ;
return FALSE ;
return false ;
}

if ((params = extractInt (progName, params, &port)) == NULL)
return FALSE ;
return false ;

if ((port < 0) || (port > 7))
{
verbError ("%s: port address (%d) out of range", progName, port) ;
return FALSE ;
return false ;
}

mcp23s08Setup (pinBase, spi, port) ;

return TRUE ;
return true ;
}


@@ -318,26 +318,26 @@ static int doExtensionMcp23s17 (char *progName, int pinBase, char *params)
int spi, port ;

if ((params = extractInt (progName, params, &spi)) == NULL)
return FALSE ;
return false ;

if ((spi < 0) || (spi > 1))
{
verbError ("%s: SPI address (%d) out of range", progName, spi) ;
return FALSE ;
return false ;
}

if ((params = extractInt (progName, params, &port)) == NULL)
return FALSE ;
return false ;

if ((port < 0) || (port > 7))
{
verbError ("%s: port address (%d) out of range", progName, port) ;
return FALSE ;
return false ;
}

mcp23s17Setup (pinBase, spi, port) ;

return TRUE ;
return true ;
}


@@ -355,26 +355,26 @@ static int doExtensionSr595 (char *progName, int pinBase, char *params)
// Extract pins

if ((params = extractInt (progName, params, &pins)) == NULL)
return FALSE ;
return false ;

if ((pins < 8) || (pins > 32))
{
verbError ("%s: pin count (%d) out of range - 8-32 expected.", progName, pins) ;
return FALSE ;
return false ;
}

if ((params = extractInt (progName, params, &data)) == NULL)
return FALSE ;
return false ;

if ((params = extractInt (progName, params, &clock)) == NULL)
return FALSE ;
return false ;

if ((params = extractInt (progName, params, &latch)) == NULL)
return FALSE ;
return false ;

sr595Setup (pinBase, pins, data, clock, latch) ;

return TRUE ;
return true ;
}


@@ -390,17 +390,17 @@ static int doExtensionPcf8574 (char *progName, int pinBase, char *params)
int i2c ;

if ((params = extractInt (progName, params, &i2c)) == NULL)
return FALSE ;
return false ;

if ((i2c < 0x03) || (i2c > 0x77))
{
verbError ("%s: i2c address (0x%X) out of range", progName, i2c) ;
return FALSE ;
return false ;
}

pcf8574Setup (pinBase, i2c) ;

return TRUE ;
return true ;
}


@@ -416,17 +416,17 @@ static int doExtensionAds1115 (char *progName, int pinBase, char *params)
int i2c ;

if ((params = extractInt (progName, params, &i2c)) == NULL)
return FALSE ;
return false ;

if ((i2c < 0x03) || (i2c > 0x77))
{
verbError ("%s: i2c address (0x%X) out of range", progName, i2c) ;
return FALSE ;
return false ;
}

ads1115Setup (pinBase, i2c) ;

return TRUE ;
return true ;
}


@@ -442,17 +442,17 @@ static int doExtensionPcf8591 (char *progName, int pinBase, char *params)
int i2c ;

if ((params = extractInt (progName, params, &i2c)) == NULL)
return FALSE ;
return false ;

if ((i2c < 0x03) || (i2c > 0x77))
{
verbError ("%s: i2c address (0x%X) out of range", progName, i2c) ;
return FALSE ;
return false ;
}

pcf8591Setup (pinBase, i2c) ;

return TRUE ;
return true ;
}


@@ -467,7 +467,7 @@ static int doExtensionPseudoPins (UNU char *progName, int pinBase, UNU char *par
{
pseudoPinsSetup (pinBase) ;

return TRUE ;
return true ;
}


@@ -482,7 +482,7 @@ static int doExtensionBmp180 (UNU char *progName, int pinBase, UNU char *params)
{
bmp180Setup (pinBase) ;

return TRUE ;
return true ;
}


@@ -497,7 +497,7 @@ static int doExtensionHtu21d (UNU char *progName, int pinBase, UNU char *params)
{
htu21dSetup (pinBase) ;

return TRUE ;
return true ;
}


@@ -513,7 +513,7 @@ static int doExtensionDs18b20 (char *progName, int pinBase, char *params)
char *serialNum ;

if ((params = extractStr (progName, params, &serialNum)) == NULL)
return FALSE ;
return false ;

return ds18b20Setup (pinBase, serialNum) ;
}
@@ -531,7 +531,7 @@ static int doExtensionRht03 (char *progName, int pinBase, char *params)
int piPin ;

if ((params = extractInt (progName, params, &piPin)) == NULL)
return FALSE ;
return false ;

return rht03Setup (pinBase, piPin) ;
}
@@ -549,17 +549,17 @@ static int doExtensionMax31855 (char *progName, int pinBase, char *params)
int spi ;

if ((params = extractInt (progName, params, &spi)) == NULL)
return FALSE ;
return false ;

if ((spi < 0) || (spi > 1))
{
verbError ("%s: SPI channel (%d) out of range", progName, spi) ;
return FALSE ;
return false ;
}

max31855Setup (pinBase, spi) ;

return TRUE ;
return true ;
}


@@ -575,17 +575,17 @@ static int doExtensionMcp3002 (char *progName, int pinBase, char *params)
int spi ;

if ((params = extractInt (progName, params, &spi)) == NULL)
return FALSE ;
return false ;

if ((spi < 0) || (spi > 1))
{
verbError ("%s: SPI channel (%d) out of range", progName, spi) ;
return FALSE ;
return false ;
}

mcp3002Setup (pinBase, spi) ;

return TRUE ;
return true ;
}


@@ -601,17 +601,17 @@ static int doExtensionMcp3004 (char *progName, int pinBase, char *params)
int spi ;

if ((params = extractInt (progName, params, &spi)) == NULL)
return FALSE ;
return false ;

if ((spi < 0) || (spi > 1))
{
verbError ("%s: SPI channel (%d) out of range", progName, spi) ;
return FALSE ;
return false ;
}

mcp3004Setup (pinBase, spi) ;

return TRUE ;
return true ;
}


@@ -627,17 +627,17 @@ static int doExtensionMax5322 (char *progName, int pinBase, char *params)
int spi ;

if ((params = extractInt (progName, params, &spi)) == NULL)
return FALSE ;
return false ;

if ((spi < 0) || (spi > 1))
{
verbError ("%s: SPI channel (%d) out of range", progName, spi) ;
return FALSE ;
return false ;
}

max5322Setup (pinBase, spi) ;

return TRUE ;
return true ;
}


@@ -653,17 +653,17 @@ static int doExtensionMcp4802 (char *progName, int pinBase, char *params)
int spi ;

if ((params = extractInt (progName, params, &spi)) == NULL)
return FALSE ;
return false ;

if ((spi < 0) || (spi > 1))
{
verbError ("%s: SPI channel (%d) out of range", progName, spi) ;
return FALSE ;
return false ;
}

mcp4802Setup (pinBase, spi) ;

return TRUE ;
return true ;
}


@@ -677,7 +677,7 @@ static int doExtensionMcp4802 (char *progName, int pinBase, char *params)
static int doExtensionSn3218 (UNU char *progName, int pinBase, UNU char *params)
{
sn3218Setup (pinBase) ;
return TRUE ;
return true ;
}


@@ -693,35 +693,35 @@ static int doExtensionMcp3422 (char *progName, int pinBase, char *params)
int i2c, sampleRate, gain ;

if ((params = extractInt (progName, params, &i2c)) == NULL)
return FALSE ;
return false ;

if ((i2c < 0x03) || (i2c > 0x77))
{
verbError ("%s: i2c address (0x%X) out of range", progName, i2c) ;
return FALSE ;
return false ;
}

if ((params = extractInt (progName, params, &sampleRate)) == NULL)
return FALSE ;
return false ;

if ((sampleRate < 0) || (sampleRate > 3))
{
verbError ("%s: sample rate (%d) out of range", progName, sampleRate) ;
return FALSE ;
return false ;
}

if ((params = extractInt (progName, params, &gain)) == NULL)
return FALSE ;
return false ;

if ((gain < 0) || (gain > 3))
{
verbError ("%s: gain (%d) out of range", progName, gain) ;
return FALSE ;
return false ;
}

mcp3422Setup (pinBase, i2c, sampleRate, gain) ;

return TRUE ;
return true ;
}


@@ -738,35 +738,35 @@ static int doExtensionDrcS (char *progName, int pinBase, char *params)
int pins, baud ;

if ((params = extractInt (progName, params, &pins)) == NULL)
return FALSE ;
return false ;

if ((pins < 1) || (pins > 1000))
{
verbError ("%s: pins (%d) out of range (2-1000)", progName, pins) ;
return FALSE ;
return false ;
}
if ((params = extractStr (progName, params, &port)) == NULL)
return FALSE ;
return false ;

if (strlen (port) == 0)
{
verbError ("%s: serial port device name required", progName) ;
return FALSE ;
return false ;
}

if ((params = extractInt (progName, params, &baud)) == NULL)
return FALSE ;
return false ;

if ((baud < 1) || (baud > 4000000))
{
verbError ("%s: baud rate (%d) out of range", progName, baud) ;
return FALSE ;
return false ;
}

drcSetupSerial (pinBase, pins, port, baud) ;

return TRUE ;
return true ;
}


@@ -784,25 +784,25 @@ static int doExtensionDrcNet (char *progName, int pinBase, char *params)
char pPort [1024] ;

if ((params = extractInt (progName, params, &pins)) == NULL)
return FALSE ;
return false ;

if ((pins < 1) || (pins > 1000))
{
verbError ("%s: pins (%d) out of range (2-1000)", progName, pins) ;
return FALSE ;
return false ;
}
if ((params = extractStr (progName, params, &ipAddress)) == NULL)
return FALSE ;
return false ;

if (strlen (ipAddress) == 0)
{
verbError ("%s: ipAddress required", progName) ;
return FALSE ;
return false ;
}

if ((params = extractStr (progName, params, &port)) == NULL)
return FALSE ;
return false ;

if (strlen (port) == 0)
{
@@ -811,12 +811,12 @@ static int doExtensionDrcNet (char *progName, int pinBase, char *params)
}

if ((params = extractStr (progName, params, &password)) == NULL)
return FALSE ;
return false ;

if (strlen (password) == 0)
{
verbError ("%s: password required", progName) ;
return FALSE ;
return false ;
}

return drcSetupNet (pinBase, pins, ipAddress, port, password) ;
@@ -883,7 +883,7 @@ int loadWPiExtension (char *progName, char *extensionData, int printErrors)
if (!*p) // ran out of characters
{
verbError ("%s: extension name not terminated by a colon", progName) ;
return FALSE ;
return false ;
}
++p ;
}
@@ -894,7 +894,7 @@ int loadWPiExtension (char *progName, char *extensionData, int printErrors)
if (!isdigit (*p))
{
verbError ("%s: decimal pinBase number expected after extension name", progName) ;
return FALSE ;
return false ;
}

while (isdigit (*p))
@@ -902,7 +902,7 @@ int loadWPiExtension (char *progName, char *extensionData, int printErrors)
if (pinBase > 2147483647) // 2^31-1 ... Lets be realistic here...
{
verbError ("%s: pinBase too large", progName) ;
return FALSE ;
return false ;
}

pinBase = pinBase * 10 + (*p - '0') ;
@@ -912,7 +912,7 @@ int loadWPiExtension (char *progName, char *extensionData, int printErrors)
if (pinBase < 64)
{
verbError ("%s: pinBase (%d) too small. Minimum is 64.", progName, pinBase) ;
return FALSE ;
return false ;
}

// Search for extensions:
@@ -924,5 +924,5 @@ int loadWPiExtension (char *progName, char *extensionData, int printErrors)
}

fprintf (stderr, "%s: extension %s not found", progName, extension) ;
return FALSE ;
return false ;
}

+ 2
- 2
wiringPiD/network.c View File

@@ -36,8 +36,8 @@

#include "network.h"

#define TRUE (1==1)
#define FALSE (!TRUE)
#define true (1==1)
#define false (!true)

// Local data



+ 1
- 1
wiringPiD/runRemote.c View File

@@ -40,7 +40,7 @@



int noLocalPins = FALSE ;
int noLocalPins = false ;


void runRemoteCommands (int fd)


+ 4
- 4
wiringPiD/wiringpid.c View File

@@ -46,7 +46,7 @@
// Globals

static const char *usage = "[-h] [-d] [-g | -1 | -z] [[-x extension:pin:params] ...] password" ;
static int doDaemon = FALSE ;
static int doDaemon = false ;

//

@@ -156,7 +156,7 @@ int main (int argc, char *argv [])
exit (EXIT_FAILURE) ;
}

doDaemon = TRUE ;
doDaemon = true ;
daemonise (PIDFILE) ;

for (i = 2 ; i < argc ; ++i)
@@ -216,7 +216,7 @@ int main (int argc, char *argv [])
for (i = 2 ; i < argc ; ++i)
argv [i - 1] = argv [i] ;
--argc ;
noLocalPins = TRUE ;
noLocalPins = true ;
++wpiSetup ;
continue ;
}
@@ -263,7 +263,7 @@ int main (int argc, char *argv [])

logMsg ("Loading extension: %s", argv [2]) ;

if (!loadWPiExtension (argv [0], argv [2], TRUE))
if (!loadWPiExtension (argv [0], argv [2], true))
{
logMsg ("Extension load failed: %s", strerror (errno)) ;
exit (EXIT_FAILURE) ;


Loading…
Cancel
Save