Lines Matching refs:buf
103 if (rt_device_read(ctx->dev, 0, ctx->buf, 1) == 1) in _rym_read_code()
104 return (enum rym_code)(*ctx->buf); in _rym_read_code()
116 rsz = rt_device_read(ctx->dev, 0, ctx->buf, 1); in _rym_read_code()
118 return (enum rym_code)(*ctx->buf); in _rym_read_code()
129 rt_uint8_t *buf = ctx->buf + 1; in _rym_read_data() local
135 0, buf + readlen, len - readlen); in _rym_read_data()
166 send_crc = CRC16(ctx->buf + 3, packetlen - 5); in _rym_send_packet()
167 ctx->buf[0] = code; in _rym_send_packet()
168 ctx->buf[1] = index; in _rym_send_packet()
169 ctx->buf[2] = index_inv; in _rym_send_packet()
170 ctx->buf[packetlen - 2] = (rt_uint8_t)(send_crc >> 8); in _rym_send_packet()
171 ctx->buf[packetlen - 1] = (rt_uint8_t)send_crc & 0xff; in _rym_send_packet()
175 writelen += rt_device_write(ctx->dev, 0, ctx->buf + writelen, in _rym_send_packet()
247 if (ctx->buf[1] != 0 || ctx->buf[2] != 0xFF) in _rym_do_handshake()
250 recv_crc = (rt_uint16_t)(*(ctx->buf + data_sz - 2) << 8) | *(ctx->buf + data_sz - 1); in _rym_do_handshake()
251 cal_crc = CRC16(ctx->buf + 3, data_sz - 5); in _rym_do_handshake()
256 if (ctx->on_begin && ctx->on_begin(ctx, ctx->buf + 3, data_sz - 5) != RYM_CODE_ACK) in _rym_do_handshake()
291 if (ctx->on_begin && ctx->on_begin(ctx, ctx->buf + 3, data_sz - 5) != RYM_CODE_SOH) in _rym_do_send_handshake()
330 if ((ctx->buf[1] + ctx->buf[2]) != 0xFF) in _rym_trans_data()
339 if (ctx->stage == RYM_STAGE_ESTABLISHED && ctx->buf[1] == 0x00) in _rym_trans_data()
348 recv_crc = (rt_uint16_t)(*(ctx->buf + tsz - 1) << 8) | *(ctx->buf + tsz); in _rym_trans_data()
349 if (recv_crc != CRC16(ctx->buf + 3, data_sz)) in _rym_trans_data()
354 *code = ctx->on_data(ctx, ctx->buf + 3, data_sz); in _rym_trans_data()
451 code = ctx->on_data(ctx, ctx->buf + 3, data_sz - 5); in _rym_do_send_trans()
481 ctx->on_end(ctx, ctx->buf + 3, 128); in _rym_do_fin()
509 if (ctx->buf[1] != 0 || ctx->buf[2] != 0xFF) in _rym_do_fin()
512 recv_crc = (rt_uint16_t)(*(ctx->buf + data_sz - 2) << 8) | *(ctx->buf + data_sz - 1); in _rym_do_fin()
513 if (recv_crc != CRC16(ctx->buf + 3, data_sz - 5)) in _rym_do_fin()
517 if (ctx->buf[3] != 0) in _rym_do_fin()
519 if (ctx->on_begin && ctx->on_begin(ctx, ctx->buf + 3, data_sz - 5) != RYM_CODE_ACK) in _rym_do_fin()
566 if (ctx->on_end && ctx->on_end(ctx, ctx->buf + 3, data_sz - 5) != RYM_CODE_SOH) in _rym_do_send_fin()
586 ctx->buf = rt_malloc(_RYM_STX_PKG_SZ); in _rym_do_recv()
587 if (ctx->buf == RT_NULL) in _rym_do_recv()
593 rt_free(ctx->buf); in _rym_do_recv()
603 rt_free(ctx->buf); in _rym_do_recv()
610 rt_free(ctx->buf); in _rym_do_recv()
622 ctx->buf = rt_malloc(_RYM_STX_PKG_SZ); in _rym_do_send()
623 if (ctx->buf == RT_NULL) in _rym_do_send()
629 rt_free(ctx->buf); in _rym_do_send()
636 rt_free(ctx->buf); in _rym_do_send()
643 rt_free(ctx->buf); in _rym_do_send()
647 rt_free(ctx->buf); in _rym_do_send()