I'm trying to connect to an Acconeer XM132 which requires RTS/CTS uart. I'm sending it register write requests as per their documentation examples, but not receiving a register write response. Specifically register write responses have a start byte of 0xCC, and I only receive 0x00.
Argon docs say:
On Gen 3 devices (Argon, Boron, Xenon), flow control is available on Serial1 D3(CTS) and D2(RTS). If you are not using flow control (the default), then these pins can be used as regular GPIO.
SERIAL_FLOW_CONTROL_NONE - no flow control
SERIAL_FLOW_CONTROL_RTS - RTS flow control
SERIAL_FLOW_CONTROL_CTS - CTS flow control
SERIAL_FLOW_CONTROL_RTS_CTS - RTS/CTS flow control
Does this mean that I just have to set Serial1.begin(115200, SERIAL_FLOW_CONTROL_RTS_CTS); and the flow control will be handled, or do I also have to manually set and reset the RTS and CTS pins? I have tried it both ways and neither has worked.
Any help would be greatly appreciated.
Code:
#define MODE_SELECTION_REGISTER 0x02
#define POWER_BINS_SERVICE 0x01
#define ENVELOPE_SERVICE 0x02
#define SPARSE_SERVICE 0x04
#define DISTANCE_SERVICE 0x200
#define PRESENCE_SERVICE 0x400#define MAIN_CONTROL_REGISTER 0x03
#define STOP_SERVICE 0x00
#define START_SERVICE 0x03#define STREAMING_CONTROL_REGISTER 0x05
#define UART_OFF 0x00
#define UART_ON 0x01#define CTS D3
#define RTS D2//#define MANUALPINS
SerialLogHandler logHandler(LOG_LEVEL_INFO);
void setup() {
Log.info("starting setup");
//Start serial communication
Serial1.begin(115200, SERIAL_FLOW_CONTROL_RTS_CTS);}
void loop() {
Log.info("you're looping");
static unsigned char register_write_response[128]; //max size of serial buffer = 128 bytes
static unsigned char register_write_request[10] = {0xCC, 0x05, 0x00, 0xF9, MAIN_CONTROL_REGISTER, STOP_SERVICE, 0x00, 0x00, 0x00, 0xCD};#if defined(MANUALPINS)
//set CTS = pin D3 low and RTS = pin D2 high to stop receiving, and transmit
pinResetFast(CTS);
pinSetFast(RTS);
#endifSerial1.write(register_write_request, 10);
#if defined(MANUALPINS)
//brief pause to make sure transmission is complete
delay(10);//set CTS high and RTS low to receive response
pinResetFast(RTS);
pinSetFast(CTS);
#endifwhile(Serial1.available()) {
//write response should start with 0xCC per acconeer docs
register_write_response[0] = Serial1.read();
}Log.info("register_write_response[0] = 0x%02X", register_write_response[0]);
delay(500);}
The result in both cases - MANUALPINS defined and not defined - is:
0000012997 [system] INFO: Cloud connected
0000012997 [app] INFO: starting setup
0000012998 [app] INFO: you're looping
0000013010 [app] INFO: register_write_response[0] = 0x00
0000013511 [app] INFO: you're looping
0000013521 [app] INFO: register_write_response[0] = 0x00
0000014022 [app] INFO: you're looping
0000014032 [app] INFO: register_write_response[0] = 0x00
0000014762 [comm.protocol] INFO: Posting 'S' describe message
0000014765 [comm.dtls] INFO: session cmd (CLS,DIS,MOV,LOD,SAV): 4
0000015011 [comm.dtls] INFO: session cmd (CLS,DIS,MOV,LOD,SAV): 3
0000015012 [comm.protocol] INFO: rcv'd message type=1
0000015012 [app] INFO: you're looping
0000015023 [app] INFO: register_write_response[0] = 0x00
0000015523 [comm.protocol] INFO: Posting 'A' describe message
0000015525 [comm.dtls] INFO: session cmd (CLS,DIS,MOV,LOD,SAV): 4
0000015525 [comm.dtls] INFO: session cmd (CLS,DIS,MOV,LOD,SAV): 3
0000015525 [comm.protocol] INFO: rcv'd message type=1
0000015526 [app] INFO: you're looping
0000015536 [app] INFO: register_write_response[0] = 0x00
0000016038 [comm.protocol] INFO: rcv'd message type=8
0000016038 [app] INFO: you're looping
0000016049 [app] INFO: register_write_response[0] = 0x00
0000016549 [app] INFO: you're looping
0000016560 [app] INFO: register_write_response[0] = 0x00
0000017060 [app] INFO: you're looping
0000017071 [app] INFO: register_write_response[0] = 0x00
0000017571 [app] INFO: you're looping
0000017582 [app] INFO: register_write_response[0] = 0x00
0000018082 [app] INFO: you're looping
0000018093 [app] INFO: register_write_response[0] = 0x00
0000018593 [app] INFO: you're looping
0000018604 [app] INFO: register_write_response[0] = 0x00
0000019104 [app] INFO: you're looping
0000019115 [app] INFO: register_write_response[0] = 0x00
0000019615 [app] INFO: you're looping