diff options
Diffstat (limited to 'pigpiod_if2.c')
-rw-r--r-- | pigpiod_if2.c | 57 |
1 files changed, 26 insertions, 31 deletions
diff --git a/pigpiod_if2.c b/pigpiod_if2.c index 85bc27c..ab2ef10 100644 --- a/pigpiod_if2.c +++ b/pigpiod_if2.c @@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to <http://unlicense.org/> */ -/* PIGPIOD_IF2_VERSION 13 */ +/* PIGPIOD_IF2_VERSION 17 */ #include <stdio.h> #include <stdlib.h> @@ -234,33 +234,10 @@ static int pigpio_command_ext return cmd.res; } -static int pigpioOpenSocket(char *addr, char *port) +static int pigpioOpenSocket(char *addrStr, char *portStr) { int sock, err, opt; struct addrinfo hints, *res, *rp; - const char *addrStr, *portStr; - - if (!addr) - { - addrStr = getenv(PI_ENVADDR); - - if ((!addrStr) || (!strlen(addrStr))) - { - addrStr = PI_DEFAULT_SOCKET_ADDR_STR; - } - } - else addrStr = addr; - - if (!port) - { - portStr = getenv(PI_ENVPORT); - - if ((!portStr) || (!strlen(portStr))) - { - portStr = PI_DEFAULT_SOCKET_PORT_STR; - } - } - else portStr = port; memset (&hints, 0, sizeof (hints)); @@ -713,11 +690,6 @@ int pigpio_start(char *addrStr, char *portStr) int pi; int *userdata; - if ((!addrStr) || (strlen(addrStr) == 0)) - { - addrStr = "localhost"; - } - for (pi=0; pi<MAX_PI; pi++) { if (!gPiInUse[pi]) break; @@ -727,6 +699,26 @@ int pigpio_start(char *addrStr, char *portStr) gPiInUse[pi] = 1; + if ((!addrStr) || (!strlen(addrStr))) + { + addrStr = getenv(PI_ENVADDR); + + if ((!addrStr) || (!strlen(addrStr))) + { + addrStr = PI_DEFAULT_SOCKET_ADDR_STR; + } + } + + if ((!portStr) || (!strlen(portStr))) + { + portStr = getenv(PI_ENVPORT); + + if ((!portStr) || (!strlen(portStr))) + { + portStr = PI_DEFAULT_SOCKET_PORT_STR; + } + } + pthread_mutex_init(&gCmdMutex[pi], NULL); gPigCommand[pi] = pigpioOpenSocket(addrStr, portStr); @@ -961,6 +953,9 @@ int wave_add_serial( int wave_create(int pi) {return pigpio_command(pi, PI_CMD_WVCRE, 0, 0, 1);} +int wave_create_and_pad(int pi, int percent) + {return pigpio_command(pi, PI_CMD_WVCAP, percent, 0, 1);} + int wave_delete(int pi, unsigned wave_id) {return pigpio_command(pi, PI_CMD_WVDEL, wave_id, 0, 1);} @@ -1293,7 +1288,7 @@ int i2c_process_call(int pi, unsigned handle, unsigned reg, uint32_t val) ext[0].ptr = &val; return pigpio_command_ext - (pi, PI_CMD_I2CPK, handle, reg, 4, 1, ext, 1); + (pi, PI_CMD_I2CPC, handle, reg, 4, 1, ext, 1); } int i2c_write_block_data( |