// Testing serial communication to EyeBot7 I/O board // Thomas Bräunl, UWA 2018 #include "eyebot.h" #define BAUD 115200 #define LEN 100 #define PARITY 0 #define BLOCK 0 int main() { char sstr[LEN], rstr[LEN]; int i; printf("Connect to EyeBot7-IO\n"); SERInit(IOBOARD, BAUD, 0); // first USB connection do { printf("Enter string: "); i=-1; do sstr[++i]=getchar(); while (sstr[i]!='\n'); sstr[i+1] = (char) 0; // terminate string printf("Send(%2d): %s", strlen(sstr), sstr); sstr[i ] = '\r'; // CR required for IO-board ... SERSend(IOBOARD, sstr); usleep(100000); // 0.1s SERReceive(IOBOARD,rstr,LEN-1); printf(" Rec(%2d): \"%s\"\n", strlen(rstr), rstr); } while (strcmp(sstr, "end\r") != 0); SERClose(IOBOARD); return 0; }