diff options
| author | Paul Kocialkowski <contact@paulk.fr> | 2012-08-12 23:06:21 +0200 |
|---|---|---|
| committer | Paul Kocialkowski <contact@paulk.fr> | 2012-08-12 23:06:21 +0200 |
| commit | b153cbd84327b97c6d1f7eacad52dab79e0c2d7e (patch) | |
| tree | 0750b710a83b3bfe810b8d49b091ff6268495af0 /utils/bcm4751_daemon.c | |
| parent | e4f94e901b9b4c5fef5642ad9580863fc2bfe336 (diff) | |
| download | bcm4751-b153cbd84327b97c6d1f7eacad52dab79e0c2d7e.tar.gz bcm4751-b153cbd84327b97c6d1f7eacad52dab79e0c2d7e.tar.bz2 bcm4751-b153cbd84327b97c6d1f7eacad52dab79e0c2d7e.zip | |
Created clean new BCM4751 gpsd code that works and prints the read data
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Diffstat (limited to 'utils/bcm4751_daemon.c')
| -rw-r--r-- | utils/bcm4751_daemon.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/utils/bcm4751_daemon.c b/utils/bcm4751_daemon.c new file mode 100644 index 0000000..3cc3190 --- /dev/null +++ b/utils/bcm4751_daemon.c @@ -0,0 +1,60 @@ +// Copyright (C) 2012 Paul Kocialkowski, contact@paulk.fr, GNU GPLv3+ +// BCM4751 daemon code + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include <arpa/inet.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <sys/un.h> +#include <sys/select.h> +#include <fcntl.h> + +#include <arpa/inet.h> +#include <netinet/in.h> + +#include <cutils/sockets.h> + +int main(void) +{ + int fd; + int cfd; + int rc; + + int clen; + char buf[50]; + char status[] = { + 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + struct sockaddr_un caddr; + + fd = socket_local_server("gps", ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_SEQPACKET); + listen(fd, 1); + printf("socket_local_server passed: %d\n", fd); + + cfd = accept(fd, 0, &clen); + printf("accept passed: %d\n", cfd); + + fd_set fds; + FD_ZERO(&fds); + FD_SET(cfd, &fds); + + while(1) + { + memset(buf, 0, sizeof(buf)); + select(cfd+1, &fds, NULL, NULL, NULL); + rc = read(cfd, buf, 50); + + printf("read %d bytes!\n", rc); + + if(rc == 50) { + write(cfd, status, sizeof(status)); + printf("wrote %d bytes!\n", sizeof(status)); + } + } + + return 0; +} |
