This commit is contained in:
joan 2015-06-01 18:32:03 +01:00
parent b68a696597
commit 573f447c78
6 changed files with 58 additions and 15 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 33 */ /* pigpio version 34 */
/* include ------------------------------------------------------- */ /* include ------------------------------------------------------- */

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 33 #define PIGPIO_VERSION 34
/*TEXT /*TEXT
@ -1956,7 +1956,7 @@ D*/
int i2cProcessCall(unsigned handle, unsigned i2cReg, unsigned wVal); int i2cProcessCall(unsigned handle, unsigned i2cReg, unsigned wVal);
/*D /*D
This writes 16 bits of data to the specified register of the device This writes 16 bits of data to the specified register of the device
associated with handle and and reads 16 bits of data in return. associated with handle and reads 16 bits of data in return.
. . . .
handle: >=0, as returned by a call to [*i2cOpen*] handle: >=0, as returned by a call to [*i2cOpen*]
@ -3742,7 +3742,7 @@ samples per second.
cfgMillis:: 100-10000 cfgMillis:: 100-10000
The size of the sample buffer in milliseconds. Gnerally this should be The size of the sample buffer in milliseconds. Generally this should be
left at the default of 120ms. If you expect intense bursts of signals it left at the default of 120ms. If you expect intense bursts of signals it
might be necessary to increase the buffer size. might be necessary to increase the buffer size.
@ -4063,7 +4063,7 @@ The number of segments in a combined I2C transaction.
offset:: offset::
The associated data starts this number of microseconds from the start of The associated data starts this number of microseconds from the start of
tghe waveform. the waveform.
*outBuf:: *outBuf::
A buffer used to return data from a function. A buffer used to return data from a function.

View File

@ -263,7 +263,7 @@ import threading
import os import os
import atexit import atexit
VERSION = "1.18" VERSION = "1.19"
exceptions = True exceptions = True

51
pigs.c
View File

@ -33,6 +33,7 @@ This version is for pigpio version 33+
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
#include <string.h> #include <string.h>
#include <ctype.h>
#include <unistd.h> #include <unistd.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/types.h> #include <sys/types.h>
@ -50,8 +51,13 @@ the commands available from pigpio.
char command_buf[8192]; char command_buf[8192];
char response_buf[8192]; char response_buf[8192];
int printFlags = 0;
#define SOCKET_OPEN_FAILED -1 #define SOCKET_OPEN_FAILED -1
#define PRINT_HEX 1
#define PRINT_ASCII 2
void fatal(char *fmt, ...) void fatal(char *fmt, ...)
{ {
char buf[128]; char buf[128];
@ -66,6 +72,30 @@ void fatal(char *fmt, ...)
fflush(stderr); fflush(stderr);
} }
static int initOpts(int argc, char *argv[])
{
int opt, args;
args = 1;
while ((opt = getopt(argc, argv, "ax")) != -1)
{
switch (opt)
{
case 'a':
printFlags |= PRINT_ASCII;
args++;
break;
case 'x':
printFlags |= PRINT_HEX;
args++;
break;
}
}
return args;
}
static int openSocket(void) static int openSocket(void)
{ {
int sock, err; int sock, err;
@ -108,7 +138,7 @@ static int openSocket(void)
void print_result(int sock, int rv, cmdCmd_t cmd) void print_result(int sock, int rv, cmdCmd_t cmd)
{ {
int i, r; int i, r, ch;
uint32_t *p; uint32_t *p;
r = cmd.res; r = cmd.res;
@ -146,9 +176,20 @@ void print_result(int sock, int rv, cmdCmd_t cmd)
if (r < 0) fatal("ERROR: %s", cmdErrStr(r)); if (r < 0) fatal("ERROR: %s", cmdErrStr(r));
if (r > 0) if (r > 0)
{ {
if (printFlags == PRINT_ASCII) printf(" ");
for (i=0; i<r; i++) for (i=0; i<r; i++)
{ {
printf(" %hhu", response_buf[i]); ch = response_buf[i];
if (printFlags & PRINT_HEX) printf(" %hhx", ch);
else if (printFlags & PRINT_ASCII)
{
if ((ch > 31) && (ch < 127)) printf("%c", ch);
else printf("\\x%02hhx", ch);
}
else printf(" %hhu", response_buf[i]);
} }
} }
printf("\n"); printf("\n");
@ -203,7 +244,7 @@ void get_extensions(int sock, int command, int res)
int main(int argc , char *argv[]) int main(int argc , char *argv[])
{ {
int sock, command; int sock, command;
int idx, i, pp, l, len; int args, idx, i, pp, l, len;
cmdCmd_t cmd; cmdCmd_t cmd;
uint32_t p[CMD_P_ARR]; uint32_t p[CMD_P_ARR];
cmdCtlParse_t ctl; cmdCtlParse_t ctl;
@ -212,11 +253,13 @@ int main(int argc , char *argv[])
sock = openSocket(); sock = openSocket();
args = initOpts(argc, argv);
command_buf[0] = 0; command_buf[0] = 0;
l = 0; l = 0;
pp = 0; pp = 0;
for (i=1; i<argc; i++) for (i=args; i<argc; i++)
{ {
l += (strlen(argv[i]) + 1); l += (strlen(argv[i]) + 1);
if (l < sizeof(command_buf)) if (l < sizeof(command_buf))

View File

@ -3,7 +3,7 @@
from distutils.core import setup from distutils.core import setup
setup(name='pigpio', setup(name='pigpio',
version='1.18', version='1.19',
author='joan', author='joan',
author_email='joan@abyz.co.uk', author_email='joan@abyz.co.uk',
maintainer='joan', maintainer='joan',

View File

@ -384,8 +384,8 @@ To the lascivious pleasing of a lute.
oc = t5_count oc = t5_count
while pi.wave_tx_busy(): while pi.wave_tx_busy():
time.sleep(0.1) time.sleep(0.2)
time.sleep(0.1) time.sleep(0.2)
c = t5_count - oc c = t5_count - oc
CHECK(5, 10, c, 1702, 0, "wave tx busy, callback") CHECK(5, 10, c, 1702, 0, "wave tx busy, callback")
@ -455,8 +455,8 @@ To the lascivious pleasing of a lute.
oc = t5_count oc = t5_count
while pi.wave_tx_busy(): while pi.wave_tx_busy():
time.sleep(0.1) time.sleep(0.2)
time.sleep(0.1) time.sleep(0.2)
c = t5_count - oc c = t5_count - oc
CHECK(5, 32, c, 1702, 0, "wave tx busy, callback") CHECK(5, 32, c, 1702, 0, "wave tx busy, callback")