/* Fordham Robotics and Computer Vision Lab. dml 7/11 */ #include /* String function definitions */ #include /* UNIX standard function definitions */ #include /* File control definitions */ #include /* Error number definitions */ #include /* POSIX terminal control definitions */ #include //#define USBSERIAL "/dev/ttyUSB0" #define SERIAL "/dev/ttyS3" #define MAXTIMEOUT 5000 #define GPSNUMSIZE 16 class serialGPS { public: serialGPS(char *devname=SERIAL) { fd = open(devname, O_RDWR | O_NOCTTY | O_NDELAY); if (fd == -1) { perror("serialGPS::open_port: Unable to open port - "); return; } else { fcntl(fd, F_SETFL, 0); } initport(fd); printf("serialGPS::Set port baud=%d\n", getbaud(fd)); fcntl(fd, F_SETFL, FNDELAY); // don't block serial read lastNorth=lastWest=0.0; locked=false; } ~serialGPS() { close(fd); } void readGPS(); double getNorth() { return lastNorth; } double getWest() { return lastWest; } bool isLocked() { return locked; } private: int initport(int fd); int writeport(int fd, char *chars); int readport(int fd, char *result); int getbaud(int fd); int fd; double lastNorth; double lastWest; char sResult[254]; bool locked; };