From ac001a6d1d05113c7520d2f3816730e1c74c8379 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Fillod=2C=20F8CFE?= Date: Mon, 11 Mar 2002 23:28:45 +0000 Subject: [PATCH] read_icom_block is gone, in favor of read_string. Thanks to Chuck Hemker. git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@1021 7ae35d74-ebe9-4afe-98af-79ac388436b8 --- icom/frame.c | 54 +++++++--------------------------------------------- icom/frame.h | 3 +-- icom/icom.c | 4 ++-- 3 files changed, 10 insertions(+), 51 deletions(-) diff --git a/icom/frame.c b/icom/frame.c index 76d91b5b7..fee42c723 100644 --- a/icom/frame.c +++ b/icom/frame.c @@ -2,7 +2,7 @@ * Hamlib CI-V backend - low level communication routines * Copyright (c) 2000-2002 by Stephane Fillod * - * $Id: frame.c,v 1.16 2002-03-10 23:44:24 fillods Exp $ + * $Id: frame.c,v 1.17 2002-03-11 23:28:45 fillods Exp $ * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as @@ -41,9 +41,6 @@ #include "icom_defs.h" #include "frame.h" -/* Prototypes */ -int read_icom_block(port_t *p, unsigned char *rxbuffer, size_t count); - /* * Build a CI-V frame. * The whole frame is placed in frame[], @@ -129,7 +126,7 @@ int icom_transaction (RIG *rig, int cmd, int subcmd, const char *payload, int pa * up to rs->retry times. */ - retval = read_icom_block(&rs->rigport, buf, frm_len); + retval = read_icom_frame(&rs->rigport, buf); if (retval != frm_len) { Unhold_Decode(rig); return retval < 0 ? retval : -RIG_EPROTO; @@ -158,29 +155,9 @@ int icom_transaction (RIG *rig, int cmd, int subcmd, const char *payload, int pa return RIG_OK; } -/* - * read count useful bytes, discarding collisions - * FIXME: check return codes/bytes read - * this function will be deprecated soon! - */ -int read_icom_block(port_t *p, unsigned char *rxbuffer, size_t count) -{ - int i; - - i = fread_block(p, rxbuffer, count); - -#if 0 - for (i=0; i 0) { - memmove(rxbuffer, rxbuffer+i, count-i); - fread_block(stream, rxbuffer+i, count-i, timeout); - } -#endif - return i; /* duh! */ -} +/* used in read_icom_frame as end of block */ +static const char icom_block_end[2] = {FI, COL}; +#define icom_block_end_length 2 /* * read_icom_frame @@ -190,26 +167,9 @@ int read_icom_block(port_t *p, unsigned char *rxbuffer, size_t count) */ int read_icom_frame(port_t *p, unsigned char rxbuffer[]) { - int i, count; + int i; - /* - * ACKFRMLEN is supposed to be the smallest frame - * we can expected on the CI-V bus - * FIXME: a COLlision is smaller!! - */ - count = fread_block(p, rxbuffer, ACKFRMLEN); - if (count != ACKFRMLEN) - return count; - - /* - * buffered read are quite helpful here! - * However, an automate with a state model would be more efficient.. - */ - for (i=ACKFRMLEN; rxbuffer[i-1]!=FI; i++) { - count = fread_block(p, rxbuffer+i, 1); - if (count != 1) - return i; - } + i = read_string(p, rxbuffer, 16, icom_block_end, icom_block_end_length); return i; } diff --git a/icom/frame.h b/icom/frame.h index a31c37611..33b01d1fd 100644 --- a/icom/frame.h +++ b/icom/frame.h @@ -2,7 +2,7 @@ * Hamlib CI-V backend - low level communication header * Copyright (c) 2000,2001 by Stephane Fillod * - * $Id: frame.h,v 1.10 2002-03-10 23:44:24 fillods Exp $ + * $Id: frame.h,v 1.11 2002-03-11 23:28:45 fillods Exp $ * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as @@ -29,7 +29,6 @@ */ int make_cmd_frame(char frame[], char re_id, char cmd, int subcmd, const char *data, int data_len); -int read_icom_block(port_t *p, unsigned char *rxbuffer, size_t count); int icom_transaction (RIG *rig, int cmd, int subcmd, const char *payload, int payload_len, char *data, int *data_len); int read_icom_frame(port_t *p, unsigned char rxbuffer[]); diff --git a/icom/icom.c b/icom/icom.c index c29df433b..7a10f7630 100644 --- a/icom/icom.c +++ b/icom/icom.c @@ -2,7 +2,7 @@ * Hamlib CI-V backend - main file * Copyright (c) 2000-2002 by Stephane Fillod * - * $Id: icom.c,v 1.56 2002-03-10 23:44:24 fillods Exp $ + * $Id: icom.c,v 1.57 2002-03-11 23:28:45 fillods Exp $ * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as @@ -2351,7 +2351,7 @@ rig_model_t probe_icom(port_t *p) /* read out the bytes we just sent * TODO: check this is what we expect */ - frm_len = read_icom_block(p, buf, frm_len); + frm_len = read_icom_frame(p, buf); /* this is the reply */ frm_len = read_icom_frame(p, buf);