Minor reordering of serial port setup.

This commit is contained in:
David Betz 2015-01-27 18:22:38 -05:00
parent b3512b52de
commit df1907fbea
2 changed files with 13 additions and 4 deletions

View File

@ -179,16 +179,18 @@ int serial_init(const char* port, unsigned long baud)
return 0;
}
fcntl(hSerial, F_SETFL, 0);
/* get the current options */
chk("tcgetattr", tcgetattr(hSerial, &old_sparm));
sparm = old_sparm;
/* set raw input */
#ifdef MACOSX
cfmakeraw(&sparm);
sparm.c_cc[VTIME] = 0;
sparm.c_cc[VMIN] = 1;
chk("cfsetspeed", cfsetspeed(&sparm, tbaud));
cfmakeraw(&sparm);
sparm.c_cc[VTIME] = 0;
sparm.c_cc[VMIN] = 1;
chk("cfsetspeed", cfsetspeed(&sparm, tbaud));
#else
memset(&sparm, 0, sizeof(sparm));
sparm.c_cflag = CS8 | CLOCAL | CREAD;

View File

@ -229,6 +229,13 @@ usage: p1load\n\
[ -v ] verbose output\n\
[ -? ] display a usage message and exit\n\
file file to load\n", BAUD_RATE);
#ifdef RASPBERRY_PI
printf("\
\n\
This version supports resetting the Propeller with a GPIO pin with option: -Dreset=gpio,pin,level\n\
where \"pin\" is the GPIO number to use and \"level\" is the logic level, 0 or 1. \n\
");
#endif
exit(1);
}