void shell_mode() { char arriving_char; char c; print_initial_prompt_lines(); while (1) { if (current_vt == CHAT_VT && serial_received()) { arriving_char = read_serial(); parse_arriving_char(arriving_char); } while ((c = getc()) == -1) ; if (current_vt == CHAT_VT) { parse_departing_char(c); } else { parse_command_char(c); } refresh_screen(); } }
int serial_getc(int port) { if (!serial_received(port)) return (-1); else return (inb(port)); }
char serial_readbyte() { if (!serial_initialized) { serial_init(); } while (serial_received() == 0); return in8(PORT); }
void SRCA::on_pushButton_clicked() // Conectar dispositivo { //select name for our serial port from combobox if (serial->portName() != ui->comboBox->currentText()) { serial->close(); serial->setPortName(ui->comboBox->currentText()); } //setup COM port serial->setBaudRate(QSerialPort::Baud9600); serial->setDataBits(QSerialPort::Data8); serial->setParity(QSerialPort::NoParity); serial->setStopBits(QSerialPort::OneStop); serial->setFlowControl(QSerialPort::NoFlowControl); serial->open(QSerialPort::ReadWrite); connect(serial,SIGNAL(readyRead()),this,SLOT(serial_received())); if(serial->portName() != NULL) ui->label->setText("Conectado em " + serial->portName()); }
char mirus::read_serial() { while (serial_received() == 0); return mirus::inb(PORT); }
//Byte empfangen unsigned int serial_read(unsigned char comport) { unsigned short base = getSerialPort(comport); while (!serial_received(base)) { } return inb(base); }
char read_serial() { while (serial_received() == 0); return inb(PORT); }
/** read_serial * returns the last char in the serial read buffer DOES NOT WORK CORRECTLY YET WE OUTPUT ALL PRINTF TO SERIAL SO WHEN WE READ SERIAL, WE SEE WHAT WE'VE OUTPUT */ char read_serial(unsigned short com){ while(serial_received(com) == 0); return inb(com); }
char serial_read(uint16_t serial_port) { while (serial_received(serial_port) == 0); return inb(serial_port); }
char serial::read_serial() { while (serial_received() == 0); return inportb(COM1_PORT); }
static void tc_event(struct serial *serial) { if (serial->dmaEvent) { serial_received(serial); } }
/** * Ticking */ static void dxl_serial_tick(volatile struct dxl_device *self) { struct serial *serial = (struct serial*)self->data; static int baudrate = DXL_DEFAULT_BAUDRATE; // Timeout on sending packet, this should never happen if (!serial->txComplete && ((millis() - serial->packetSent) > 3)) { serial_received(serial); } /* if (!serial->txComplete) { if (serial->dmaEvent) { // DMA completed serial->dmaEvent = false; serial->txComplete = true; //serial->port->waitDataToBeSent(); receiveMode(serial); serial->syncReadStart = syncReadTimer.getCount(); } } */ if (serial->txComplete) { if (syncReadMode) { bool processed = false; if (syncReadDevices <= 0 && syncReadResponse == &self->packet) { // The process is over, no devices are currently trying to get packet and we // are the device that will respond syncReadResponse->process = true; syncReadMode = false; } else if (serial->syncReadCount) { if (serial->syncReadCurrent == 0xff) { // Sending the first packet serial->syncReadCurrent = 0; syncReadSendPacket(serial); } else { // Reading available data from the port while (serial->port->available() && !serial->syncReadPacket.process) { dxl_packet_push_byte(&serial->syncReadPacket, serial->port->read()); } if (serial->syncReadPacket.process && serial->syncReadPacket.parameter_nb == syncReadLength) { // The packet is OK, copying data to the response at correct offset ui8 i; ui8 off = serial->syncReadOffsets[serial->syncReadCurrent]*(syncReadLength+1); syncReadResponse->parameters[off] = serial->syncReadPacket.error; for (i=0; i<syncReadLength; i++) { syncReadResponse->parameters[off+1+i] = serial->syncReadPacket.parameters[i]; } processed = true; } else if (syncReadTimer.getCount()-serial->syncReadStart > 65) { // The timeout is reached, answer with code 0xff ui8 off = serial->syncReadOffsets[serial->syncReadCurrent]*(syncReadLength+1); syncReadResponse->parameters[off] = 0xff; processed = true; } if (processed) { serial->syncReadCurrent++; if (serial->syncReadCurrent >= serial->syncReadCount) { // The process is over for this bus syncReadDevices--; serial->syncReadCount = 0; } else { // Sending the next packet syncReadSendPacket(serial); } } } } } else { if (self->redirect_packets == NULL && baudrate != usb_cdcacm_get_baud()) { // baudrate = usb_cdcacm_get_baud(); // initSerial(serial, baudrate); } // Reading data that come from the serial bus while (serial->port->available() && !self->packet.process) { dxl_packet_push_byte(&self->packet, serial->port->read()); if (self->packet.process) { // A packet is coming from our bus, noting it in the devices allocation // table devicePorts[self->packet.id] = serial->index; } } } } }