код взят из примеров производителя шлюза rs232<>1-wire DS2480.
//--------------------------------------------------------------------------
// Write an array of bytes to the COM port, verify that it was sent out. Assume that baud rate has been set.
//
// 'outlen' - number of bytes to write to COM port
// 'outbuf' - pointer ot an array of bytes to write
//
// Returns: TRUE(1) - success
// FALSE(0) - failure
//
int WriteCOM(int fd, int outlen, unsigned char *outbuf){
unsigned i;
int size_written;
// timer timeout vars
struct sigevent ev;
// timeout
_Uint64t ui_timeout;
// calculate a timeout
ui_timeout = (80)*mSEC_NSEC;
ev.sigev_notify = SIGEV_UNBLOCK;
// write the byte
for ( i=0;i<outlen;i++) {
TimerTimeout( CLOCK_REALTIME, _NTO_TIMEOUT_SEND | _NTO_TIMEOUT_REPLY, &ev, &ui_timeout, NULL );
size_written=write(fd , &outbuf[i] , 1);
tcdrain(fd);
if (size_written !=1 ){
printf("transmit timeout \n");
return 0;
}
msDelay(2);
}
if (dodebug) { //debug
for ( i = 0; i < outlen; i++) printf(">%02X",outbuf[i]);
printf("\n");
}
// check results of write
return 1;
}

Ответ на:
комментарий
от cvv

Ответ на:
комментарий
от cvv
Ответ на:
комментарий
от alexd

Ответ на:
комментарий
от cvv
Ответ на:
комментарий
от idle

Ответ на:
комментарий
от cvv
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.
Похожие темы
- Форум не видит com порт (2007)
- Форум Чтение запись COM порта (2018)
- Форум g++ expects argument (2013)
- Форум libusb (2011)
- Форум CMSPAR and PARODD (2022)
- Форум ChatGPT (2023)
- Форум Драйвер чтения и записи (2013)
- Форум [нубский вопрос] оптимальность кода (2009)
- Форум Правильно портировать Pascal код (2018)
- Новости Опубликован код файловой системы ОС QNX (2008)