diff options
Diffstat (limited to 'components/utilities/zmodem/zdevice.c')
| -rw-r--r-- | components/utilities/zmodem/zdevice.c | 102 |
1 files changed, 51 insertions, 51 deletions
diff --git a/components/utilities/zmodem/zdevice.c b/components/utilities/zmodem/zdevice.c index 1562cc5f5c..3a144e79de 100644 --- a/components/utilities/zmodem/zdevice.c +++ b/components/utilities/zmodem/zdevice.c @@ -3,7 +3,7 @@ * the implemention of zmodem protocol. * Change Logs: * Date Author Notes - * 2011-03-29 itspy + * 2011-03-29 itspy */ #include <rtthread.h> @@ -15,11 +15,11 @@ #include <dfs_posix.h> #include "zdef.h" - -rt_uint32_t Line_left = 0; /* left number of data in the read line buffer*/ -rt_uint32_t Left_sizes = 0; /* left file sizes */ -rt_uint32_t Baudrate = BITRATE; /* console baudrate */ - + +rt_uint32_t Line_left = 0; /* left number of data in the read line buffer*/ +rt_uint32_t Left_sizes = 0; /* left file sizes */ +rt_uint32_t Baudrate = BITRATE; /* console baudrate */ + rt_uint32_t get_device_baud(void) @@ -34,7 +34,7 @@ rt_uint32_t get_sys_time(void) void zsend_byte(rt_uint16_t ch) { - rt_device_write(zmodem.device, 0, &ch,1); + rt_device_write(zmodem.device, 0, &ch,1); return; } @@ -43,38 +43,38 @@ void zsend_line(rt_uint16_t c) { rt_uint16_t ch; - ch = (c & 0377); - rt_device_write(zmodem.device, 0, &ch, 1); + ch = (c & 0377); + rt_device_write(zmodem.device, 0, &ch, 1); return; } rt_int16_t zread_line(rt_uint16_t timeout) { - char *str; - static char buf[10]; + char *str; + static char buf[10]; - if (Line_left > 0) - { - Line_left -= 1; - return (*str++ & 0377); - } - Line_left = 0; - timeout/=5; - while (1) - { - Line_left = rt_device_read(shell->device, 0, buf, 1); - if (Line_left) - { - Line_left = Line_left; - str = buf; - break; - } - } - if (Line_left < 1) return TIMEOUT; - Line_left -=1; + if (Line_left > 0) + { + Line_left -= 1; + return (*str++ & 0377); + } + Line_left = 0; + timeout/=5; + while (1) + { + Line_left = rt_device_read(shell->device, 0, buf, 1); + if (Line_left) + { + Line_left = Line_left; + str = buf; + break; + } + } + if (Line_left < 1) return TIMEOUT; + Line_left -=1; - return (*str++ & 0377); + return (*str++ & 0377); } /* @@ -83,32 +83,32 @@ rt_int16_t zread_line(rt_uint16_t timeout) */ void zsend_break(char *cmd) { - - while (*cmd++) - { - switch (*cmd) - { - case '\336': - continue; - case '\335': - rt_thread_delay(RT_TICK_PER_SECOND); - continue; - default: - zsend_line(*cmd); - break; - } - } + + while (*cmd++) + { + switch (*cmd) + { + case '\336': + continue; + case '\335': + rt_thread_delay(RT_TICK_PER_SECOND); + continue; + default: + zsend_line(*cmd); + break; + } + } } /* send cancel string to get the other end to shut up */ void zsend_can(void) { - static char cmd[] = {24,24,24,24,24,24,24,24,24,24,0}; + static char cmd[] = {24,24,24,24,24,24,24,24,24,24,0}; - zsend_break(cmd); - rt_kprintf("\x0d"); - Line_left=0; /* clear Line_left */ + zsend_break(cmd); + rt_kprintf("\x0d"); + Line_left=0; /* clear Line_left */ - return; + return; } /* end of zdevice.c */ |
