📄 hms800.c
字号:
// Pointer to the bytes to be written.
// Return: None.
// Side effects: None.
void BLWriteTx(WORD start_add, WORD data_size, WORD timeout, BYTE *data_buf)
{ // Preform a normal block write.
do_BLWrite(start_add, data_size, timeout, data_buf, BLK_WRITE);
}
// ****************************************************************************
// Transmit get tag's Identification number Command
// Input: Antenna timeout time.
// Return: None.
// Side effects: None.
void Get_Tag_IDTx(WORD timeout)
{
BYTE tx_buf[6];
BYTE *data_ptr;
WORD buf_size;
data_ptr = tx_buf;
buf_size = 6;
*data_ptr++ = MSG_BEGIN;
*data_ptr++ = GET_TAG_ID;
*data_ptr++ = (BYTE)(timeout / 256);
*data_ptr++ = (BYTE)(timeout % 256);
*data_ptr++ = MSG_TERM;
*data_ptr = MSG_TERM;
#if ANTARES
com_buf_clr(); // Clear out Anyares COM receive buffer.
#endif
SendStream(tx_buf, buf_size);
}
// ****************************************************************************
// Transmit Tag Search Command
// Input: Antenna timeout time.
// Return: None.
// Side effects: None.
void SearchTx(WORD timeout)
{
BYTE tx_buf[6];
BYTE *data_ptr;
WORD buf_size;
data_ptr = tx_buf;
buf_size = 6;
*data_ptr++ = MSG_BEGIN;
*data_ptr++ = SEARCH_TAG;
*data_ptr++ = (BYTE)(timeout / 256);
*data_ptr++ = (BYTE)(timeout % 256);
*data_ptr++ = MSG_TERM;
*data_ptr = MSG_TERM;
#if ANTARES
com_buf_clr(); // Clear out Anyares COM receive buffer.
#endif
SendStream(tx_buf, buf_size);
}
// ****************************************************************************
// Transmit the Change baud rate
// Input: New baud rate value. (See Operators's Manual for antenna.)
// Return: None.
// Side effects: None.
void BaudrateTx(WORD baudrate)
{
BYTE tx_buf[6];
tx_buf[MSG_BEG_INX] = MSG_BEGIN;
tx_buf[MSG_FUN_INX] = BAUD_CHANG;
tx_buf[2] = (BYTE)(baudrate / 256);
tx_buf[3] = (BYTE)(baudrate % 256);
tx_buf[4] = MSG_TERM;
tx_buf[5] = MSG_TERM;
#if ANTARES
com_buf_clr(); // Clear out Anyares COM receive buffer.
#endif
SendStream(tx_buf, BAUD_CHANGE_CMDSIZE);
}
// ****************************************************************************
// Recevive response form Non-Contiguous read.
// Input: Pointer to where the data can be place.
// Do not more than the data size number of bytes.
// Return: Read status.
// Side effects: None.
BYTE NCReadRx(BYTE *data_buf, WORD data_size)
{
BYTE *rx_buf;
BYTE status;
WORD ii;
//allocate buffer and initialize them
rx_buf = build_buf;
ClearBuf(rx_buf, data_size*2 + 4);
#if TEST_MUX32
if(NOT com_rec_buf(rx_buf, 2, REC_FIRST_BYTE)) // Throw out the first two bytes.
status = COMM_FAIL; // They are MUX32 address and stuff.
else
#endif
// first check the first 2 bytes to find out what is expected
// if even the first 2 bytes are not gotten, serial communication fails
// if get 0xff in 2nd bytes, receive Error message
// else may get right message
if (NOT com_rec_buf(rx_buf, 2, REC_FIRST_BYTE))
{
status = COMM_FAIL;
} else if (rx_buf[MSG_FUN_INX] EQ 0xff)
{
if (NOT com_rec_buf(rx_buf+2, 4, REC_BYTES_TIME))
{
status = COMM_FAIL;
} else
{
status = rx_buf[3];
}
} else
{
if (com_rec_buf(rx_buf + 2, data_size*2 + 2, REC_MORE_BYTES) AND
(rx_buf[MSG_BEG_INX] EQ MSG_BEGIN) AND (rx_buf[MSG_FUN_INX] EQ NONCO_READ))
{
status = OP_OK;
for(ii = 0; ii < data_size; ii++)
*data_buf++ = rx_buf[3 + ii*2];
} else
status = COMM_INV;
}
return(status);
}
// ****************************************************************************
// Receive response from Non-Contiguous write.
// Input: None.
// Return: Was the command echoed?
// Side effects: None.
BYTE NCWriteRx(void)
{
//MSG_BEGIN, NONCO_WRITE, MSG_TERM, MSG_TERM if OK
//MSG_BEGIN, 0xFF, 0x00, Error_Code, MSG_TERM, MSG_TERM if wrong
return(RxCheck(NONCO_WRITE));
}
// ****************************************************************************
// Receive response from Non-Contiguous configuration.
// Input: None.
// Return: Was the command echoed?
// Side effects: None.
BYTE NCConfRx(void)
{
return(RxCheck(CONF_NONCO));
}
// ****************************************************************************
// Receive response from fill command.
// Input: None.
// Return: Was the command echoed?
// Side effects: None.
BYTE FillRx(void)
{
#if ANTARES
im_standby_wait(500); // Wait a half a second.
#else
delay(500); // Wait a half a second.
#endif
return(RxCheck(FILL_TAG));
}
// ****************************************************************************
// Receive response from Block Read.
// Input: where to place the data.
// Receive no more data than this. Note: BYTE received in a WORD.
// Return: Command status.
// Side effects: None.
BYTE BLReadRx(BYTE *data_buf, WORD data_size)
{
return(do_BLReadRx(data_buf, data_size, BLK_READ));
}
// ****************************************************************************
// Receive response from COM2 write command.
// Input: Pointer to where to place the response packet data.
// Timeout value sent with the command. Wait atleast this long.
// Maximun number of bytes to receive.
// Return: Command status.
// Side effects: None.
BYTE COM2_inpx_Rx(BYTE *rx_buf, WORD time_out, BYTE max_length)
{
return(do_COMReadRx(rx_buf, max_length, time_out, COM2_READX));
}
// ****************************************************************************
// Receive response from COM2 write line command.
// Input: Pointer to where to place the response packet data.
// Timeout value sent with the command. Wait atleast this long.
// Maximun number of bytes to receive.
// Return: Command status.
// Side effects: None.
BYTE COM2_line_Rx(BYTE *rx_buf, WORD time_out, BYTE max_length)
{
return(do_COMReadRx(rx_buf, max_length, time_out, COM2_READ_TERM));
}
// ****************************************************************************
// Receive response from COM2 write command.
// Input: None.
// Return: Command status.
// Side effects: None.
BYTE write_COM2Rx(void)
{
return(RxCheck(COM2_WRITE));
}
// ****************************************************************************
// Receive response from COM2 clear receive buffer command.
// Input: None.
// Return: Command status.
// Side effects: None.
BYTE COM2clearRx(void)
{
return(RxCheck(COM2_CLEAR));
}
// ****************************************************************************
// Receive response from Continual Block Read.
// NOTE: This was renamed and is called the
// HMS827 Initiate/Cancel Infinite Block Read command.
//
// Input: where to place the data.
// Receive no more data than this. Note: BYTE received in a WORD.
// Return: Command status.
// Side effects: None.
BYTE ContBLReadRx(BYTE *data_buf, WORD data_size)
{
return(do_BLReadRx(data_buf, data_size, CON_READ_MODE));
}
// ****************************************************************************
// Receive a data response from Continuous Block Read command.
// NOTE: This is the new Continuous Block Read mode data response packet.
//
// Input: where to place the data.
// Receive no more data than this. Note: BYTE received in a WORD.
// Return: Command status.
// Side effects: None.
BYTE BLReadContinuousRx(BYTE *data_buf, WORD data_size)
{
return(do_BLReadRx(data_buf, data_size, CONT_READ));
}
// ****************************************************************************
// Receive response from block write.
// Input: None.
// Return: Was the command echoed?
// Side effects: None.
BYTE BLWriteRx(void)
{
return(RxCheck(BLK_WRITE));
}
// ****************************************************************************
// Receive response get tag's Identification number command.
// Input: Pointer to buffer to place the tag's ID in.
// Number of bytes in this tag ID.
// Return: Was the command echoed? Tag present?
// Side effects: None.
BYTE Get_Tag_IDRx(BYTE *data_buf, WORD id_size)
{
return(do_BLReadRx(data_buf, id_size, GET_TAG_ID));
}
// ****************************************************************************
// Receive response from search tag.
// Input: None.
// Return: Was the command echoed? Tag present?
// Side effects: None.
BYTE SearchRx(void)
{
return(RxCheck(SEARCH_TAG));
}
// ****************************************************************************
// Receive response from Protected Write Block command.
// Input: None.
// Return: Was the command echoed? Tag present?
// Side effects: None.
BYTE pro_BLWriteRx(void)
{
return(RxCheck(PRO_BL_WRITE));
}
// ****************************************************************************
// Receive response from Enter Continual Read mode command.
// Input: None.
// Return: Was the command echoed? Tag present?
// Side effects: None.
BYTE ContReadRx(void)
{
return(RxCheck(CON_READ_MODE));
}
// ****************************************************************************
// Receive response from Enter Continuous Block Read mode command.
// Input: None.
// Return: Was the command echoed? Tag present?
// Side effects: None.
BYTE ContinuousRx(void)
{
return(RxCheck(CONT_READ));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -