+int send_wait_hmuartlgw(struct hm_dev *dev, struct recv_data *rdata, uint8_t *data, int data_len,
+ enum hmuartlgw_dst dst, enum hmuartlgw_state srcstate,
+ enum hmuartlgw_state dststate)
+{
+ int cnt = 5;
+
+ do {
+ rdata->uartlgw_state = srcstate;
+ hmuartlgw_send(dev->hmuartlgw, data, data_len, dst);
+ do { hmuartlgw_poll(dev->hmuartlgw, 500); } while (rdata->uartlgw_state != dststate);
+ if (rdata->status != HMUARTLGW_ACK_EINPROGRESS)
+ break;
+ usleep(200*1000);
+ } while (cnt--);
+ if (rdata->status == HMUARTLGW_ACK_EINPROGRESS) {
+ fprintf(stderr, "IO thinks it is busy, you might have to reset it!\n");
+ return 0;
+ }
+
+ return 1;
+}
+