All pastes #468771 Raw Edit

C

public c v1 · immutable
·published 2007-05-03 10:44 UTC
rendered paste body
#include <fcntl.h>#include <sys/ioctl.h>#include <stdio.h>#include <termios.h>#define GPS_DEV "/dev/ttySAC1"#define GPS_SYNC "\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80"#define GPS_INIT "\xff\x0c\xfd\xc0\x00\xfc\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \                 "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \                 "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \                 "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"int main(int argc, char *argv[]){	int fd;	struct termios t;	char buf[512];	char *p;	int n;	fd = open(GPS_DEV, O_RDWR|O_NOCTTY);	ioctl(fd, TCGETS, &t);	cfsetospeed(&t, B115200);	cfmakeraw(&t);	t.c_cflag &= ~CRTSCTS;	ioctl(fd, TCSETS, &t);	write(fd, GPS_SYNC, 16);	write(fd, GPS_INIT, 64);	n = read(fd, buf, sizeof(buf));	printf("(%d) \n", n);	p = buf;	while (n--)		printf("%02x ", *p++);	printf("\n");}