DAINCUBE DTP10-L Ручной огонь - Страница 6

Просмотреть онлайн или скачать pdf Ручной огонь для Контроллер DAINCUBE DTP10-L. DAINCUBE DTP10-L 13 страниц. Embedded-based teach pendant optimized for industrial robots, arm cortex-a9 linux system

/* Flush the input and output */
tcflush ( fd, TCIOFLUSH );
/* Set the new options for the port */
tcsetattr( fd, TCSANOW, &newtio );
notRsRead = new QSocketNotifier(fd, QSocketNotifier::Read, this);
connect(notRsRead, SIGNAL(activated(int)), this, SLOT(Receive_Event()));
ui->Btn_Open->setEnabled(1);
/* Ring buffer create */
m_abyBuffer.Create(BUFF_MAX);
Open_uinput_port();
}
}
2.2. Write packet to serial port
The method of writing packet to serial port is as follows. Transmit serial packet through the write function.
Example )
/*
* Function name : on_Btn_LED1_clicked
* Description
: This function is control Right LED 1.
*/
void Serial_Daemon::on_Btn_LED1_clicked()
{
char LED_Packet[10] = {0, };
unsigned int crc_buf;
unsigned long dwBytes = 0;
static char i = 0;
LED_Packet[0] = STX;
LED_Packet[1] = MOD_SET;
LED_Packet[2] = SEL_LED;
LED_Packet[3] = RIGHT_LED1;
if ( i == 3 )
LED_Packet[4] = LED_OFF;
0x33)
else
LED_Packet[4] = LED_BLUE + i;
LED_Packet[5] = DATA_RESERVED;
crc_buf = crc16_append(LED_Packet,6);
LED_Packet[6] = (char)(crc_buf>>8)&0xff;
LED_Packet[7] = (char)crc_buf&0xff;
LED_Packet[8] = ETX;
LED_Packet[9] = '\0';
dwBytes = strlen(LED_Packet);
write( fd, LED_Packet, dwBytes );
usleep(1000);
switch (i) {
case 0 :
ui->Btn_LED1->setText("BLUE");
i++;
break;
case 1 :
ui->Btn_LED1->setText("RED");
i++;
// STX
// MOD (get : 0x10, set : 0x11)
// SEL (LED : 0x3A)
// Data1 (SUB ADDRESS)
// Data2 (off : 0x30, blue : 0x31, red : 0x32, all :
// Data3 (Reserved : 0x20)
// ETX