long xmodem_recv(char *buf) { int r, receiving = 0; long size = 0; unsigned char c, block_number = 1; while (1) { if (!receiving) xmodem_wait(); c = serial_recv_byte(SERIAL_DEFAULT_DEVICE); if (c == XMODEM_EOT) { serial_send_byte(SERIAL_DEFAULT_DEVICE, XMODEM_ACK); break; } else if (c == XMODEM_CAN) { return -1; } else if (c == XMODEM_SOH) { receiving++; r = xmodem_read_block(block_number, buf); if (r < 0) { serial_send_byte(SERIAL_DEFAULT_DEVICE, XMODEM_NAK); } else { block_number++; size += r; buf += r; serial_send_byte(SERIAL_DEFAULT_DEVICE, XMODEM_ACK); } } else { if (receiving) return -1; } } return size; }
int putc(unsigned char c) { if (c == '\n') serial_send_byte(SERIAL_DEFAULT_DEVICE,'\r'); return serial_send_byte(SERIAL_DEFAULT_DEVICE,c); }
int putc(char c) { if (c == '\n') { serial_send_byte(SERIAL_DEFAULT_DEVICE, '\r'); } return serial_send_byte(SERIAL_DEFAULT_DEVICE, c); }
/* send single charactor */ int putc(unsigned char c) { /* convert a new line code */ if (c == '\n') { serial_send_byte(SERIAL_DEFAULT_DEVICE, '\r'); } return serial_send_byte(SERIAL_DEFAULT_DEVICE, c); }
void serial_puts(const char *s) { while (*s) { serial_send_byte(*s++); } }
static void send_char(struct consreg *cons) { int i; serial_send_byte(cons->index, cons->send_buf[0]); cons->send_len--; for(i=0;i < cons->send_len; i++) cons->send_buf[i] = cons->send_buf[i + 1]; }
/* 送信バッファの先頭1文字を送信する */ static void send_char(struct consreg *cons) { int i; serial_send_byte(cons->index, cons->send_buf[0]); cons->send_len--; /* 先頭文字を送信したので,1文字ぶんずらす */ for (i = 0; i < cons->send_len; i++) cons->send_buf[i] = cons->send_buf[i + 1]; }
void serial_send_byte(char c) { S3C24X0_UART *const uart = (S3C24X0_UART *) ELFIN_UART_BASE; /* wait for room in the tx FIFO */ while (!(uart->UTRSTAT & 0x2)) ; uart->UTXH = c; if (c == '\n') /* If \n, also do \r */ serial_send_byte('\r'); }
static int xmodem_wait(void) { long cnt = 0; while (!serial_is_recv_enable(SERIAL_DEFAULT_DEVICE)) { if (++cnt >= 2000000) { cnt = 0; serial_send_byte(SERIAL_DEFAULT_DEVICE, XMODEM_NAK); } } return 0; }
long xmodem_recv(char *buf) { int r, receiving = 0; long size = 0; unsigned char c, block_number = 1; while (1) { if (!receiving) xmodem_wait(); /* 受信開始されるまで送信要求を出す */ c = serial_recv_byte(SERIAL_DEFAULT_DEVICE); if (c == XMODEM_EOT) { /* 受信終了 */ serial_send_byte(SERIAL_DEFAULT_DEVICE, XMODEM_ACK); break; } else if (c == XMODEM_CAN) { /* 受信中断 */ return -1; } else if (c == XMODEM_SOH) { /* 受信開始 */ receiving++; r = xmodem_read_block(block_number, buf); /* ブロック単位での受信 */ if (r < 0) { /* 受信エラー */ serial_send_byte(SERIAL_DEFAULT_DEVICE, XMODEM_NAK); } else { /* 正常受信 */ block_number++; size += r; buf += r; serial_send_byte(SERIAL_DEFAULT_DEVICE, XMODEM_ACK); } } else { if (receiving) return -1; } } return size; }
/******************************************************************//** * @brief putc * @param * @return *********************************************************************/ int16_t kz_putc(uint8_t c) { if (c == '\n') serial_send_byte('\r'); return serial_send_byte(c); }
static void putDebugChar(char c) { serial_send_byte(SERIAL_DEFAULT_DEVICE, c); }