Exemplo n.º 1
0
int main() {
    /* Select output serial 2 = UART2, 6 = UART6 */
    serial_select(UART2);
    
    while (1){
        printf("\nInt count: %d", t2);
        udelay(1000000);
   }
    
    return 0;
}
Exemplo n.º 2
0
static void serial_update(devserial_t *serial)
{
	if(serial_select(serial->sock, 0))
	{
    int client = accept (serial->sock, NULL, NULL);
		
		if(serial->remote >= 0) {
			const char *msg = "Another client is already connected.\nGood Bye!\n";
			write(client, msg , strlen(msg));
			close(client);
		} else {
			serial->remote = client;
		}
	}
}
Exemplo n.º 3
0
static void serial_write(devserial_t *serial, uint16_t reg, uint32_t value)
{
	uint8_t bits = value;
	switch (reg)
	{
	case SERIAL_REG_DATA:
		if(serial->remote >= 0) {
			if(serial_select(serial->remote, 1)) {
				if(send(serial->remote, &bits, 1, MSG_NOSIGNAL) <= 0) {
					serial->remote = -1;
				}
			}
		}
		break;
	}
}
Exemplo n.º 4
0
static uint32_t serial_read(devserial_t *serial, uint16_t reg)
{
	uint8_t bits;
	switch (reg)
	{
	case SERIAL_REG_DATA: 
		if(serial->remote >= 0 && serial_select(serial->remote, 0)) {
			if(read(serial->remote, &bits, 1) <= 0) {
				serial->remote = -1;
				return -1;
			}
			return bits;
		} else {
			return -1;
		}
	default:
		return -1;
	}
}
Exemplo n.º 5
0
int device_select(struct timeval *timeout, struct gn_statemachine *state)
{
	switch (state->device.type) {
	case GN_CT_DKU2:
	case GN_CT_Serial:
	case GN_CT_Infrared:
		return serial_select(state->device.fd, timeout, state);
	case GN_CT_Irda:
		return irda_select(state->device.fd, timeout, state);
	case GN_CT_Bluetooth:
		return bluetooth_select(state->device.fd, timeout, state);
	case GN_CT_Tekram:
		return tekram_select(state->device.fd, timeout, state);
	case GN_CT_TCP:
		return tcp_select(state->device.fd, timeout, state);
	case GN_CT_DKU2LIBUSB:
		return fbusdku2usb_select(timeout, state);
	case GN_CT_SOCKETPHONET:
		return socketphonet_select(state->device.fd, timeout, state);
	default:
		break;
	}
	return -1;
}
Exemplo n.º 6
0
int socketphonet_select(int fd, struct timeval *timeout, struct gn_statemachine *state)
{
	return serial_select(fd, timeout, state);
}
Exemplo n.º 7
0
int tcp_select(int fd, struct timeval *timeout, struct gn_statemachine *state)
{
	return serial_select(fd, timeout, state);
}