result_t ser_print(char *string, int number) { size_t length; char *format = " : 0x"; u8_t number_string[8]; length = strlen(string); if(ser_write((u8_t *)string, length) != SUCCESS) { return FAILURE; } if(ser_write(gen_add_base(format), 5) != SUCCESS) { return FAILURE; } itoa(number, (char *)number_string, 16); if(ser_write(number_string, strlen((char *)number_string)) != SUCCESS) { return FAILURE; } if(ser_write(gen_add_base("\r\n"), 2) != SUCCESS) { return FAILURE; } return SUCCESS; }
void ser_print(const char *p) { while (*p) { char c = *p++; if (c == '\n') ser_write('\r'); ser_write(c); } }
static void ser_print_hex1(unsigned int n) { n &= 15; if (n < 10) { ser_write('0' + n); } else { ser_write('A' - 10 + n); } }
/** * Write data to SPI bus. */ static size_t spimaster_write(struct KFile *fd, const void *buf, size_t size) { Serial *fd_spi = SERIAL_CAST(fd); ser_purgeRx(fd_spi); return ser_write(&fd_spi->fd, buf, size); }
Errcode slow_to_wacom(SHORT port, char *s) /* send a string out serial port with a delay afterwards */ { ser_write(port,s,strlen(s)); flush_write(port); wait_milli(150); return(ser_status(port)); }
// Send a packet to the serial port static void send_response_packet() { u16 temp16; // Send request if( remotefs_get_packet_size( rfs_buffer, &temp16 ) != REMOTEFS_ERR ) { log_msg( "send_response_packet: sending response packet of %u bytes\n", ( unsigned )temp16 ); ser_write( ser, rfs_buffer, temp16 ); } }
void transport_write_buffer( Transport *tpt, const u8 *buffer, int length ) { int n; struct exception e; TRANSPORT_VERIFY_OPEN; n = ser_write( tpt->fd, buffer, length ); if ( n != length ) { e.errnum = transport_errno; e.type = fatal; Throw( e ); } }
// Write a byte to the serial port u32 ser_write_byte( ser_handler id, u8 data ) { return ser_write( id, &data, 1 ); }
// Write a byte to the serial port u32 ser_write_byte( int id, u8 data ) { return ( u32 )ser_write( id, &data, (u32) 1 ); }
Errcode wac_input(Idriver *idr) { static char wlinebuf[32]; char *s = wlinebuf; int count = sizeof(wlinebuf)-2; int c; int stype; int temp; int dp; int ux,uy; SHORT port = idr->comm_port; ser_write(port, "RQ1\n", 4); flush_write(port); while (--count >= 0) { if ((c = timeout_get_char(port)) < Success) { return(c); } if ((*s++ = c) == '\n') break; } *s = 0; s = wlinebuf; switch (*s++) /* see what first character of packet says it is */ { case '!': stype = PSTYLUS; break; case '#': stype = STYLUS; break; case '*': stype = PUCK; /* it's a puck */ break; default: flush_read(port); return(Err_version); } s = skip_past_comma(s); ux = atoi(s) - 120; s = skip_past_comma(s); uy = atoi(s) - 120; s = skip_past_comma(s); temp = atoi(s); switch (stype) { case PSTYLUS: idr->buttons = 0; wac_pos[2] = 0; if (temp > -99 && temp < 99) /* filter to reasonable values */ { wac_pos[0] = ux; wac_pos[1] = uy; if (temp < pmin) pmin = temp; if (temp > pmax) pmax = temp; dp = pmax-(pmin+PTHRESH); temp -= pmin+PTHRESH; if (temp > 0) { wac_pos[2] = temp*PMAX/dp; idr->buttons = 1; } } /* check for control key to interpret a right click (Arr, no side button on pressure sensitive stylus!) */ if (jkey_shift() & 0x4) /* right button on control key */ idr->buttons |= 0x2; break; case STYLUS: if (temp != 99) { wac_pos[0] = ux; wac_pos[1] = uy; idr->buttons = temp; } break; case PUCK: idr->buttons = 0; if (temp != 99) { wac_pos[0] = ux; wac_pos[1] = uy; if (temp&2) idr->buttons |= 1; if (temp&4) idr->buttons |= 2; } break; } return(Success); }
static u32 transport_ser_send( const u8 *p, u32 size ) { TRANSPORT_SER *pser = ( TRANSPORT_SER* )transport_data; return ser_write( pser->fd, p, size ); }