summaryrefslogtreecommitdiff
path: root/apps/system/zmodem/zm_proto.c
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-07-12 19:06:00 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-07-12 19:06:00 -0600
commit92c70c86d8d7c023e16c87a1bd39cc0d7981d017 (patch)
tree8ed4dbf5116f25acc765d05caacd43e24835e809 /apps/system/zmodem/zm_proto.c
parente77e09228c953f36872e0674ba98e4358f46b109 (diff)
downloadnuttx-92c70c86d8d7c023e16c87a1bd39cc0d7981d017.tar.gz
nuttx-92c70c86d8d7c023e16c87a1bd39cc0d7981d017.tar.bz2
nuttx-92c70c86d8d7c023e16c87a1bd39cc0d7981d017.zip
More Zmodem-related changes
Diffstat (limited to 'apps/system/zmodem/zm_proto.c')
-rw-r--r--apps/system/zmodem/zm_proto.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/apps/system/zmodem/zm_proto.c b/apps/system/zmodem/zm_proto.c
index 4ef1c143d..9af600f8a 100644
--- a/apps/system/zmodem/zm_proto.c
+++ b/apps/system/zmodem/zm_proto.c
@@ -169,8 +169,8 @@ FAR uint8_t *zm_putzdle(FAR struct zm_state_s *pzm, FAR uint8_t *buffer,
* (ZBIN or ZBIN32 format assumed, ZCRCW terminator is always used)
*
* Input Parameters:
- * pzm - Zmodem session state
- * buffer - Buffer of data to be sent (must not be pzm->rcvbuf)
+ * pzm - Zmodem session state
+ * buffer - Buffer of data to be sent
* buflen - The number of bytes in buffer to be sent
*
****************************************************************************/
@@ -178,21 +178,24 @@ FAR uint8_t *zm_putzdle(FAR struct zm_state_s *pzm, FAR uint8_t *buffer,
int zm_senddata(FAR struct zm_state_s *pzm, FAR const uint8_t *buffer,
size_t buflen)
{
- uint8_t *ptr = pzm->rcvbuf;
+ uint8_t *ptr = pzm->scratch;
ssize_t nwritten;
uint32_t crc;
uint8_t zbin;
uint8_t term;
+ int i;
/* Make select ZBIN or ZBIN32 format and the ZCRCW terminator */
if ((pzm->flags & ZM_FLAG_CRC32) != 0)
{
zbin = ZBIN32;
+ crc = 0xffffffff;
}
else
{
zbin = ZBIN;
+ crc = 0;
}
term = ZCRCW;
@@ -200,7 +203,6 @@ int zm_senddata(FAR struct zm_state_s *pzm, FAR const uint8_t *buffer,
/* Transfer the data to the I/O buffer, accumulating the CRC */
- crc = (zbin == ZBIN) ? 0 : 0xffffffff;
while (buflen-- > 0)
{
if (zbin == ZBIN)
@@ -243,7 +245,7 @@ int zm_senddata(FAR struct zm_state_s *pzm, FAR const uint8_t *buffer,
else
{
crc = ~crc;
- for (buflen = 4; --buflen >= 0; crc >>= 8)
+ for (i = 0; i < 4; i++, crc >>= 8)
{
ptr = zm_putzdle(pzm, ptr, crc & 0xff);
}
@@ -251,7 +253,7 @@ int zm_senddata(FAR struct zm_state_s *pzm, FAR const uint8_t *buffer,
/* Send the header */
- nwritten = zm_remwrite(pzm->remfd, pzm->rcvbuf, ptr - pzm->rcvbuf);
+ nwritten = zm_remwrite(pzm->remfd, pzm->scratch, ptr - pzm->scratch);
return nwritten < 0 ? (int)nwritten : OK;
}