V62
authorjoan <joan@abyz.co.uk>
Mon, 24 Apr 2017 20:05:43 +0000 (21:05 +0100)
committerjoan <joan@abyz.co.uk>
Mon, 24 Apr 2017 20:05:43 +0000 (21:05 +0100)
pigpio.c
pigpio.h
pigpiod_if.c
pigpiod_if.h
pigpiod_if2.c
pigpiod_if2.h

index 4e5286f722a5f6d7733192819722c32f5053b83d..8310e314975247f7bcf8b06cfa9bf1d653efd0d7 100644 (file)
--- a/pigpio.c
+++ b/pigpio.c
@@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 For more information, please refer to <http://unlicense.org/>
 */
 
-/* pigpio version 61 */
+/* pigpio version 62 */
 
 /* include ------------------------------------------------------- */
 
@@ -4395,6 +4395,8 @@ static void spiGoS(
                  SPI_CS_CSPOL(cspol)   |
                  SPI_CS_CLEAR(3);
 
+   spiReg[SPI_DLEN] = 2; /* undocumented, stops inter-byte gap */
+
    spiReg[SPI_CS] = spiDefaults; /* stop */
 
    if (!count) return;
@@ -4925,6 +4927,8 @@ int serReadByte(unsigned handle)
 
 int serWrite(unsigned handle, char *buf, unsigned count)
 {
+   int written=0, wrote=0;
+
    DBG(DBG_USER, "handle=%d count=%d [%s]",
       handle, count, myBuf2Str(count, buf));
 
@@ -4939,7 +4943,19 @@ int serWrite(unsigned handle, char *buf, unsigned count)
    if (!count)
       SOFT_ERROR(PI_BAD_PARAM, "bad count (%d)", count);
 
-   if (write(serInfo[handle].fd, buf, count) != count)
+   while ((written != count) && (wrote >= 0))
+   {
+      wrote = write(serInfo[handle].fd, buf+written, count-written);
+
+      if (wrote >= 0)
+      {
+         written += wrote;
+
+         if (written != count) time_sleep(0.05);
+      }
+   }
+
+   if (written != count)
       return PI_SER_WRITE_FAILED;
    else
       return 0;
@@ -8703,6 +8719,8 @@ int gpioPWM(unsigned gpio, unsigned val)
       switchFunctionOff(gpio);
 
       gpioInfo[gpio].is = GPIO_PWM;
+
+      if (!val) myGpioWrite(gpio, 0);
    }
 
    myGpioSetMode(gpio, PI_OUTPUT);
@@ -8940,6 +8958,8 @@ int gpioServo(unsigned gpio, unsigned val)
       switchFunctionOff(gpio);
 
       gpioInfo[gpio].is = GPIO_SERVO;
+
+      if (!val) myGpioWrite(gpio, 0);
    }
 
    myGpioSetMode(gpio, PI_OUTPUT);
index 57137c399a8d781cbefcc9a5ebd0f1d68f31c297..192006a8f1dba0c608282151b008ca174a14ed73 100644 (file)
--- a/pigpio.h
+++ b/pigpio.h
@@ -31,7 +31,7 @@ For more information, please refer to <http://unlicense.org/>
 #include <stdint.h>
 #include <pthread.h>
 
-#define PIGPIO_VERSION 61
+#define PIGPIO_VERSION 62
 
 /*TEXT
 
index 3840968a45907b640ded3c806d1044e1f075d32a..4219a4f239fc572d8c18af33b9c696ad342220fe 100644 (file)
@@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 For more information, please refer to <http://unlicense.org/>
 */
 
-/* PIGPIOD_IF_VERSION 25 */
+/* PIGPIOD_IF_VERSION 26 */
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -492,6 +492,11 @@ void stop_thread(pthread_t *pth)
 
 int pigpio_start(char *addrStr, char *portStr)
 {
+   if ((!addrStr) || (strlen(addrStr) == 0))
+   {
+      addrStr = "localhost";
+   }
+
    if (!gPigStarted)
    {
       gPigCommand = pigpioOpenSocket(addrStr, portStr);
index 6200a798c295f7634e1488492c5b67aa702e128c..8714eab8a816541a33e200eef1405751919bfac1 100644 (file)
@@ -30,7 +30,7 @@ For more information, please refer to <http://unlicense.org/>
 
 #include "pigpio.h"
 
-#define PIGPIOD_IF_VERSION 25
+#define PIGPIOD_IF_VERSION 26
 
 /*TEXT
 
index d94732a707648b97754494c6a224b293dbcdb344..86b779ab430669a3d349d07083e9ec2f67f4e5ab 100644 (file)
@@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 For more information, please refer to <http://unlicense.org/>
 */
 
-/* PIGPIOD_IF2_VERSION 9 */
+/* PIGPIOD_IF2_VERSION 10 */
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -713,6 +713,11 @@ 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;
index 0ed67199b6813ab4b0a7a41e7ba0660f2074e664..73eb0e8ab19f15f379ae0f30b66410c06cdc942f 100644 (file)
@@ -30,7 +30,7 @@ For more information, please refer to <http://unlicense.org/>
 
 #include "pigpio.h"
 
-#define PIGPIOD_IF2_VERSION 9
+#define PIGPIOD_IF2_VERSION 10
 
 /*TEXT