kopia lustrzana https://github.com/Hamlib/Hamlib
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-79ac388436b8Hamlib-1.1.3
rodzic
cf86d350ff
commit
ac001a6d1d
54
icom/frame.c
54
icom/frame.c
|
@ -2,7 +2,7 @@
|
||||||
* Hamlib CI-V backend - low level communication routines
|
* Hamlib CI-V backend - low level communication routines
|
||||||
* Copyright (c) 2000-2002 by Stephane Fillod
|
* 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
|
* This library is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Library General Public License as
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
@ -41,9 +41,6 @@
|
||||||
#include "icom_defs.h"
|
#include "icom_defs.h"
|
||||||
#include "frame.h"
|
#include "frame.h"
|
||||||
|
|
||||||
/* Prototypes */
|
|
||||||
int read_icom_block(port_t *p, unsigned char *rxbuffer, size_t count);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Build a CI-V frame.
|
* Build a CI-V frame.
|
||||||
* The whole frame is placed in 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.
|
* 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) {
|
if (retval != frm_len) {
|
||||||
Unhold_Decode(rig);
|
Unhold_Decode(rig);
|
||||||
return retval < 0 ? retval : -RIG_EPROTO;
|
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;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* used in read_icom_frame as end of block */
|
||||||
* read count useful bytes, discarding collisions
|
static const char icom_block_end[2] = {FI, COL};
|
||||||
* FIXME: check return codes/bytes read
|
#define icom_block_end_length 2
|
||||||
* 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<count; i++) {
|
|
||||||
if (rxbuffer[i] != COL)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (i > 0) {
|
|
||||||
memmove(rxbuffer, rxbuffer+i, count-i);
|
|
||||||
fread_block(stream, rxbuffer+i, count-i, timeout);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return i; /* duh! */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* read_icom_frame
|
* 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 read_icom_frame(port_t *p, unsigned char rxbuffer[])
|
||||||
{
|
{
|
||||||
int i, count;
|
int i;
|
||||||
|
|
||||||
/*
|
i = read_string(p, rxbuffer, 16, icom_block_end, icom_block_end_length);
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Hamlib CI-V backend - low level communication header
|
* Hamlib CI-V backend - low level communication header
|
||||||
* Copyright (c) 2000,2001 by Stephane Fillod
|
* 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
|
* This library is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Library General Public License as
|
* 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 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 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[]);
|
int read_icom_frame(port_t *p, unsigned char rxbuffer[]);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Hamlib CI-V backend - main file
|
* Hamlib CI-V backend - main file
|
||||||
* Copyright (c) 2000-2002 by Stephane Fillod
|
* 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
|
* This library is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Library General Public License as
|
* 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
|
/* read out the bytes we just sent
|
||||||
* TODO: check this is what we expect
|
* 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 */
|
/* this is the reply */
|
||||||
frm_len = read_icom_frame(p, buf);
|
frm_len = read_icom_frame(p, buf);
|
||||||
|
|
Ładowanie…
Reference in New Issue