This commit is contained in:
joan 2017-04-24 21:05:43 +01:00
parent 114653357b
commit c4c8ce50c6
6 changed files with 37 additions and 7 deletions

View File

@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/> For more information, please refer to <http://unlicense.org/>
*/ */
/* pigpio version 61 */ /* pigpio version 62 */
/* include ------------------------------------------------------- */ /* include ------------------------------------------------------- */
@ -4395,6 +4395,8 @@ static void spiGoS(
SPI_CS_CSPOL(cspol) | SPI_CS_CSPOL(cspol) |
SPI_CS_CLEAR(3); SPI_CS_CLEAR(3);
spiReg[SPI_DLEN] = 2; /* undocumented, stops inter-byte gap */
spiReg[SPI_CS] = spiDefaults; /* stop */ spiReg[SPI_CS] = spiDefaults; /* stop */
if (!count) return; if (!count) return;
@ -4925,6 +4927,8 @@ int serReadByte(unsigned handle)
int serWrite(unsigned handle, char *buf, unsigned count) int serWrite(unsigned handle, char *buf, unsigned count)
{ {
int written=0, wrote=0;
DBG(DBG_USER, "handle=%d count=%d [%s]", DBG(DBG_USER, "handle=%d count=%d [%s]",
handle, count, myBuf2Str(count, buf)); handle, count, myBuf2Str(count, buf));
@ -4939,7 +4943,19 @@ int serWrite(unsigned handle, char *buf, unsigned count)
if (!count) if (!count)
SOFT_ERROR(PI_BAD_PARAM, "bad count (%d)", 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; return PI_SER_WRITE_FAILED;
else else
return 0; return 0;
@ -8703,6 +8719,8 @@ int gpioPWM(unsigned gpio, unsigned val)
switchFunctionOff(gpio); switchFunctionOff(gpio);
gpioInfo[gpio].is = GPIO_PWM; gpioInfo[gpio].is = GPIO_PWM;
if (!val) myGpioWrite(gpio, 0);
} }
myGpioSetMode(gpio, PI_OUTPUT); myGpioSetMode(gpio, PI_OUTPUT);
@ -8940,6 +8958,8 @@ int gpioServo(unsigned gpio, unsigned val)
switchFunctionOff(gpio); switchFunctionOff(gpio);
gpioInfo[gpio].is = GPIO_SERVO; gpioInfo[gpio].is = GPIO_SERVO;
if (!val) myGpioWrite(gpio, 0);
} }
myGpioSetMode(gpio, PI_OUTPUT); myGpioSetMode(gpio, PI_OUTPUT);

View File

@ -31,7 +31,7 @@ For more information, please refer to <http://unlicense.org/>
#include <stdint.h> #include <stdint.h>
#include <pthread.h> #include <pthread.h>
#define PIGPIO_VERSION 61 #define PIGPIO_VERSION 62
/*TEXT /*TEXT

View File

@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/> For more information, please refer to <http://unlicense.org/>
*/ */
/* PIGPIOD_IF_VERSION 25 */ /* PIGPIOD_IF_VERSION 26 */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -492,6 +492,11 @@ void stop_thread(pthread_t *pth)
int pigpio_start(char *addrStr, char *portStr) int pigpio_start(char *addrStr, char *portStr)
{ {
if ((!addrStr) || (strlen(addrStr) == 0))
{
addrStr = "localhost";
}
if (!gPigStarted) if (!gPigStarted)
{ {
gPigCommand = pigpioOpenSocket(addrStr, portStr); gPigCommand = pigpioOpenSocket(addrStr, portStr);

View File

@ -30,7 +30,7 @@ For more information, please refer to <http://unlicense.org/>
#include "pigpio.h" #include "pigpio.h"
#define PIGPIOD_IF_VERSION 25 #define PIGPIOD_IF_VERSION 26
/*TEXT /*TEXT

View File

@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/> For more information, please refer to <http://unlicense.org/>
*/ */
/* PIGPIOD_IF2_VERSION 9 */ /* PIGPIOD_IF2_VERSION 10 */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -713,6 +713,11 @@ int pigpio_start(char *addrStr, char *portStr)
int pi; int pi;
int *userdata; int *userdata;
if ((!addrStr) || (strlen(addrStr) == 0))
{
addrStr = "localhost";
}
for (pi=0; pi<MAX_PI; pi++) for (pi=0; pi<MAX_PI; pi++)
{ {
if (!gPiInUse[pi]) break; if (!gPiInUse[pi]) break;

View File

@ -30,7 +30,7 @@ For more information, please refer to <http://unlicense.org/>
#include "pigpio.h" #include "pigpio.h"
#define PIGPIOD_IF2_VERSION 9 #define PIGPIOD_IF2_VERSION 10
/*TEXT /*TEXT