On 6/27/05, Anze <[EMAIL PROTECTED]> wrote:
Hehe, sem ze ugotovil...
blocking, canonical
Po parih ukazih. Povsem nedeterministicno. Sedaj imam celo obcutek, da je prislo do neke napake na kontrolerju, ker se enota neprestano kalibrira...
Poslati moram samo presledek (takoj, ko enota dobi presledek zacne izvajati ukaz).
Tule je del, ki poskrbi za inicializacijo:
// Open modem device for reading and writing and not as controlling tty
// because we don't want to get killed if linenoise sends CTRL-C.
this->fd = open(_deviceName, O_RDWR | O_NOCTTY);
// Were there problems?
if (this->fd < 0)
{
fprintf(stderr, "Opening the specified device ... ERROR\n");
exit(-1);
} // if
// Save the current serial port settings.
tcgetattr(this->fd, &(this->oldIoSettings));
// Reset the new settings.
bzero(&(this->dpPtuSettings), sizeof(this->dpPtuSettings));
// Setup the serial port.
// Set the baud rate to 9600, 8 data bits, no parity and 1 stop bit.
// Use local connection (no modem control).
// Enable receiving charaters.
this->dpPtuSettings.c_cflag = CS8 | CLOCAL | CREAD | ECHO;
// Ignore bytes with parity errors and map CR to NL.
this->dpPtuSettings.c_iflag = IGNPAR | ICRNL;
// Set the raw output.
this->dpPtuSettings.c_oflag = 0;
// Enable cacnonical input.
this->dpPtuSettings.c_lflag = ICANON;
// Set output and input speed.
cfsetospeed(&(this->dpPtuSettings), B9600);
cfsetispeed(&(this->dpPtuSettings), B9600);
// Clean the serial line and activate the settings for the port.
tcflush(this->fd, TCIFLUSH);
tcsetattr(this->fd, TCSANOW, &(this->dpPtuSettings));
Hvala za tvojo pomoc, bom tudi to pogledal. Ko mi uspe enoto prepricat, da se neha kalibrirat... :)
lp,Zivjo!
Na sleep pozabi - razen ce tvoja enota to izrecno zahteva, si bos samo
zakompliciral zivljenje, ce bos to uporabljal.
Hehe, sem ze ugotovil...
Sicer pa:
- kaksen nacin komuniciranja uporabljas (blocking / non-blocking; canonical /
non-canonical; ...)
blocking, canonical
- kaj pomeni "vsake toliko casa zacne sprejemati neumnosti" - po celem dnevu
delovanja ali po nekaj minutah?
Po parih ukazih. Povsem nedeterministicno. Sedaj imam celo obcutek, da je prislo do neke napake na kontrolerju, ker se enota neprestano kalibrira...
- ali posiljas za ukazi tudi "\r\n"? Bi moral?
Poslati moram samo presledek (takoj, ko enota dobi presledek zacne izvajati ukaz).
Se najbolje bi bilo, ce bi poslal inicializacijsko kodo.
Tule je del, ki poskrbi za inicializacijo:
// Open modem device for reading and writing and not as controlling tty
// because we don't want to get killed if linenoise sends CTRL-C.
this->fd = open(_deviceName, O_RDWR | O_NOCTTY);
// Were there problems?
if (this->fd < 0)
{
fprintf(stderr, "Opening the specified device ... ERROR\n");
exit(-1);
} // if
// Save the current serial port settings.
tcgetattr(this->fd, &(this->oldIoSettings));
// Reset the new settings.
bzero(&(this->dpPtuSettings), sizeof(this->dpPtuSettings));
// Setup the serial port.
// Set the baud rate to 9600, 8 data bits, no parity and 1 stop bit.
// Use local connection (no modem control).
// Enable receiving charaters.
this->dpPtuSettings.c_cflag = CS8 | CLOCAL | CREAD | ECHO;
// Ignore bytes with parity errors and map CR to NL.
this->dpPtuSettings.c_iflag = IGNPAR | ICRNL;
// Set the raw output.
this->dpPtuSettings.c_oflag = 0;
// Enable cacnonical input.
this->dpPtuSettings.c_lflag = ICANON;
// Set output and input speed.
cfsetospeed(&(this->dpPtuSettings), B9600);
cfsetispeed(&(this->dpPtuSettings), B9600);
// Clean the serial line and activate the settings for the port.
tcflush(this->fd, TCIFLUSH);
tcsetattr(this->fd, TCSANOW, &(this->dpPtuSettings));
> Se vecji problem je v tem, da, ko se to zgodi, pan-tilt sprejema ukaze v
> nedogled. Pomaga sele reboot masine.
Poleg Serial Programming HOWTO je vsaj meni precej pomagalo brskanje po
newsgroupih (Google Groups) - HOWTO ni dovolj natancen v nekaterih
(pomembnih!) podrobnostih.
Hvala za tvojo pomoc, bom tudi to pogledal. Ko mi uspe enoto prepricat, da se neha kalibrirat... :)
Gregor
_______________________________________________ lugos-prog mailing list [email protected] http://liste2.lugos.si/cgi-bin/mailman/listinfo/lugos-prog
