summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPeter Osterlund <petero2@telia.com>2005-01-06 00:08:10 +0100
committerPeter Osterlund <petero2@telia.com>2006-04-09 04:03:03 +0200
commit996d47af5768c12fd45d9f1804ef6b952acddf7b (patch)
tree02c5a3c99d2eaddaa555302ef31c4860d56955b8 /test
parentad7c167063c328723d094fd413d48e54fcdcd6d2 (diff)
Cosmetic changes.
Diffstat (limited to 'test')
-rw-r--r--test/test-pad.c164
-rw-r--r--test/testprotocol.c3
2 files changed, 84 insertions, 83 deletions
diff --git a/test/test-pad.c b/test/test-pad.c
index 96c06cb..f4c27e9 100644
--- a/test/test-pad.c
+++ b/test/test-pad.c
@@ -6,116 +6,116 @@
#include <string.h>
#include <errno.h>
-int getbyte(int fd, unsigned char *b)
+int
+getbyte(int fd, unsigned char *b)
{
- return(read(fd, b, 1) == 1);
+ return(read(fd, b, 1) == 1);
}
-int putbyte(int fd, unsigned char b)
+int
+putbyte(int fd, unsigned char b)
{
- unsigned char ack;
+ unsigned char ack;
-printf("write %02X\n", b);
- if(write(fd, &b, 1) != 1)
- {
- fprintf(stderr, "error write: %s\n", strerror(errno));
- return 0;
- }
+ printf("write %02X\n", b);
+ if (write(fd, &b, 1) != 1) {
+ fprintf(stderr, "error write: %s\n", strerror(errno));
+ return 0;
+ }
- if(!getbyte(fd, &ack))
- {
- fprintf(stderr, "error read: %s\n", strerror(errno));
- return 0;
- }
-printf("read %02X\n", ack);
+ if (!getbyte(fd, &ack)) {
+ fprintf(stderr, "error read: %s\n", strerror(errno));
+ return 0;
+ }
+ printf("read %02X\n", ack);
- if(ack != 0xFA)
- {
- fprintf(stderr, "error ack\n");
- return 0;
- }
+ if (ack != 0xFA) {
+ fprintf(stderr, "error ack\n");
+ return 0;
+ }
- return 1;
+ return 1;
}
-int special_cmd(int fd, unsigned char cmd)
+int
+special_cmd(int fd, unsigned char cmd)
{
- int i;
-
- if(putbyte(fd, 0xE6))
- for(i=0; i<4; i++)
- {
-printf("special_cmd %i\n", i);
- if((!putbyte(fd, 0xE8)) || (!putbyte(fd, (cmd>>6)&0x3)))
- return 0;
- cmd<<=2;
- }
- else
+ int i;
+
+ if (putbyte(fd, 0xE6))
+ for (i = 0; i < 4; i++) {
+ printf("special_cmd %i\n", i);
+ if ((!putbyte(fd, 0xE8)) || (!putbyte(fd, (cmd>>6)&0x3)))
return 0;
- return 1;
+ cmd<<=2;
+ }
+ else
+ return 0;
+ return 1;
}
-int send_cmd(int fd, unsigned char cmd)
+int
+send_cmd(int fd, unsigned char cmd)
{
- return(special_cmd(fd, cmd) && putbyte(fd, 0xE9));
+ return (special_cmd(fd, cmd) &&
+ putbyte(fd, 0xE9));
}
-int identify(int fd, unsigned long int *ident)
+int
+identify(int fd, unsigned long int *ident)
{
- unsigned char id[3];
-
- if(send_cmd(fd, 0x00) && getbyte(fd, &id[0]) && getbyte(fd, &id[1]) && getbyte(fd, &id[2]))
- {
- *ident = (id[0]<<16)|(id[1]<<8)|id[2];
- printf("ident %06X\n", *ident);
- return 1;
- } else {
- fprintf(stderr, "error identify\n");
- return 0;
- }
+ unsigned char id[3];
+
+ if (send_cmd(fd, 0x00) &&
+ getbyte(fd, &id[0]) &&
+ getbyte(fd, &id[1]) &&
+ getbyte(fd, &id[2])) {
+ *ident = (id[0]<<16)|(id[1]<<8)|id[2];
+ printf("ident %06X\n", *ident);
+ return 1;
+ } else {
+ fprintf(stderr, "error identify\n");
+ return 0;
+ }
}
-int reset(int fd)
+int
+reset(int fd)
{
- unsigned char r[2];
-
- if(!putbyte(fd, 0xFF))
- {
- fprintf(stderr, "error reset\n");
- return 0;
- }
+ unsigned char r[2];
- sleep(5);
-
- if(getbyte(fd, &r[0]) && getbyte(fd, &r[1]))
- if(r[0] == 0xAA && r[1] == 0x00)
- {
- fprintf(stderr, "reset done\n");
- return 1;
- }
- fprintf(stderr, "error reset ack\n");
+ if (!putbyte(fd, 0xFF)) {
+ fprintf(stderr, "error reset\n");
return 0;
-}
-
+ }
+ sleep(5);
+ if (getbyte(fd, &r[0]) && getbyte(fd, &r[1]))
+ if (r[0] == 0xAA && r[1] == 0x00) {
+ fprintf(stderr, "reset done\n");
+ return 1;
+ }
+ fprintf(stderr, "error reset ack\n");
+ return 0;
+}
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
- int fd;
- unsigned long int ident;
-
- fd = open("/dev/psaux", O_RDWR);
- if(fd == -1)
- {
- fprintf(stderr, "error open: %s\n", strerror(errno));
- exit(0);
- }
+ int fd;
+ unsigned long int ident;
- reset(fd);
- identify(fd, &ident);
+ fd = open("/dev/psaux", O_RDWR);
+ if (fd == -1) {
+ fprintf(stderr, "error open: %s\n", strerror(errno));
+ exit(0);
+ }
- close(fd);
+ reset(fd);
+ identify(fd, &ident);
- exit(0);
+ close(fd);
+
+ exit(0);
}
diff --git a/test/testprotocol.c b/test/testprotocol.c
index 51758be..178dc96 100644
--- a/test/testprotocol.c
+++ b/test/testprotocol.c
@@ -59,7 +59,8 @@ SynapticsReadPacket(int fd)
}
}
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
{
int fd;