diff options
author | PaulK <contact@paulk.fr> | 2012-03-18 17:39:18 +0100 |
---|---|---|
committer | PaulK <contact@paulk.fr> | 2012-03-18 17:39:18 +0100 |
commit | e4f94e901b9b4c5fef5642ad9580863fc2bfe336 (patch) | |
tree | e76ac49be65b47c654c953a4c30bf67577a91453 /bcm4751_daemon.c | |
parent | 576f7826e43786d6293bae8887f1b6551247a092 (diff) | |
download | bcm4751-e4f94e901b9b4c5fef5642ad9580863fc2bfe336.tar.gz bcm4751-e4f94e901b9b4c5fef5642ad9580863fc2bfe336.tar.bz2 bcm4751-e4f94e901b9b4c5fef5642ad9580863fc2bfe336.zip |
Added daemon, hal and lib modules and solved serial setup for bcm4751_test
Diffstat (limited to 'bcm4751_daemon.c')
-rw-r--r-- | bcm4751_daemon.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/bcm4751_daemon.c b/bcm4751_daemon.c new file mode 100644 index 0000000..3cc3190 --- /dev/null +++ b/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; +} |