aciodrv: fix pointer format, and missing close context

This commit is contained in:
Will Xyen
2021-01-14 11:05:46 -08:00
parent 4cba227d1c
commit 841d34065d
3 changed files with 18 additions and 18 deletions
+12 -12
View File
@@ -19,7 +19,7 @@ struct aciodrv_device_ctx {
uint8_t node_count; uint8_t node_count;
}; };
static bool aciodrv_device_init(struct aciodrv_device_ctx* device) static bool aciodrv_device_init(struct aciodrv_device_ctx *device)
{ {
uint8_t init_seq[1] = {AC_IO_SOF}; uint8_t init_seq[1] = {AC_IO_SOF};
uint8_t read_buff[1] = {0x00}; uint8_t read_buff[1] = {0x00};
@@ -60,7 +60,7 @@ aciodrv_device_log_buffer(const char *msg, const uint8_t *buffer, int length)
} }
#endif #endif
static bool aciodrv_device_send(struct aciodrv_device_ctx* device, const uint8_t *buffer, int length) static bool aciodrv_device_send(struct aciodrv_device_ctx *device, const uint8_t *buffer, int length)
{ {
uint8_t send_buf[512]; uint8_t send_buf[512];
int send_buf_pos = 0; int send_buf_pos = 0;
@@ -109,7 +109,7 @@ static bool aciodrv_device_send(struct aciodrv_device_ctx* device, const uint8_t
return true; return true;
} }
static int aciodrv_device_receive(struct aciodrv_device_ctx* device, uint8_t *buffer, int max_resp_size) static int aciodrv_device_receive(struct aciodrv_device_ctx *device, uint8_t *buffer, int max_resp_size)
{ {
uint8_t recv_buf[512]; uint8_t recv_buf[512];
int recv_size = 0; int recv_size = 0;
@@ -206,7 +206,7 @@ static int aciodrv_device_receive(struct aciodrv_device_ctx* device, uint8_t *bu
return -1; return -1;
} }
static uint8_t aciodrv_device_enum_nodes(struct aciodrv_device_ctx* device) static uint8_t aciodrv_device_enum_nodes(struct aciodrv_device_ctx *device)
{ {
struct ac_io_message msg; struct ac_io_message msg;
@@ -228,7 +228,7 @@ static uint8_t aciodrv_device_enum_nodes(struct aciodrv_device_ctx* device)
return msg.cmd.count; return msg.cmd.count;
} }
static bool aciodrv_device_get_version(struct aciodrv_device_ctx* device, uint8_t node_id, char product[4]) static bool aciodrv_device_get_version(struct aciodrv_device_ctx *device, uint8_t node_id, char product[4])
{ {
struct ac_io_message msg; struct ac_io_message msg;
@@ -266,7 +266,7 @@ static bool aciodrv_device_get_version(struct aciodrv_device_ctx* device, uint8_
return true; return true;
} }
static bool aciodrv_device_start_node(struct aciodrv_device_ctx* device, uint8_t node_id) static bool aciodrv_device_start_node(struct aciodrv_device_ctx *device, uint8_t node_id)
{ {
struct ac_io_message msg; struct ac_io_message msg;
@@ -286,14 +286,14 @@ static bool aciodrv_device_start_node(struct aciodrv_device_ctx* device, uint8_t
return true; return true;
} }
struct aciodrv_device_ctx* aciodrv_device_open(const char *port_path, int baud) struct aciodrv_device_ctx *aciodrv_device_open(const char *port_path, int baud)
{ {
HANDLE port = aciodrv_port_open(port_path, baud); HANDLE port = aciodrv_port_open(port_path, baud);
if (!port) { if (!port) {
return NULL; return NULL;
} }
struct aciodrv_device_ctx* device = malloc(sizeof(struct aciodrv_device_ctx)); struct aciodrv_device_ctx *device = malloc(sizeof(struct aciodrv_device_ctx));
device->fd = port; device->fd = port;
@@ -326,12 +326,12 @@ struct aciodrv_device_ctx* aciodrv_device_open(const char *port_path, int baud)
return device; return device;
} }
uint8_t aciodrv_device_get_node_count(struct aciodrv_device_ctx* device) uint8_t aciodrv_device_get_node_count(struct aciodrv_device_ctx *device)
{ {
return device->node_count; return device->node_count;
} }
bool aciodrv_device_get_node_product_ident(struct aciodrv_device_ctx* device, uint8_t node_id, char product[4]) bool aciodrv_device_get_node_product_ident(struct aciodrv_device_ctx *device, uint8_t node_id, char product[4])
{ {
if (device->node_count == 0 || node_id > device->node_count) { if (device->node_count == 0 || node_id > device->node_count) {
return false; return false;
@@ -341,7 +341,7 @@ bool aciodrv_device_get_node_product_ident(struct aciodrv_device_ctx* device, ui
return true; return true;
} }
bool aciodrv_send_and_recv(struct aciodrv_device_ctx* device, struct ac_io_message *msg, int max_resp_size) bool aciodrv_send_and_recv(struct aciodrv_device_ctx *device, struct ac_io_message *msg, int max_resp_size)
{ {
msg->cmd.seq_no = device->msg_counter++; msg->cmd.seq_no = device->msg_counter++;
int send_size = offsetof(struct ac_io_message, cmd.raw) + msg->cmd.nbytes; int send_size = offsetof(struct ac_io_message, cmd.raw) + msg->cmd.nbytes;
@@ -377,7 +377,7 @@ bool aciodrv_send_and_recv(struct aciodrv_device_ctx* device, struct ac_io_messa
return true; return true;
} }
void aciodrv_device_close(struct aciodrv_device_ctx* device) void aciodrv_device_close(struct aciodrv_device_ctx *device)
{ {
aciodrv_port_close(device->fd); aciodrv_port_close(device->fd);
+5 -5
View File
@@ -16,7 +16,7 @@ struct aciodrv_device_ctx;
* @param baud Baud rate for communication (e.g. 57600 for ICCA) * @param baud Baud rate for communication (e.g. 57600 for ICCA)
* @return opened device context, NULL on error * @return opened device context, NULL on error
*/ */
struct aciodrv_device_ctx* aciodrv_device_open(const char *port_path, int baud); struct aciodrv_device_ctx *aciodrv_device_open(const char *port_path, int baud);
/** /**
* Get the node count on the opened device. * Get the node count on the opened device.
@@ -24,7 +24,7 @@ struct aciodrv_device_ctx* aciodrv_device_open(const char *port_path, int baud);
* @param device Context of opened device * @param device Context of opened device
* @return Total num of nodes enumerated on the ACIO device. * @return Total num of nodes enumerated on the ACIO device.
*/ */
uint8_t aciodrv_device_get_node_count(struct aciodrv_device_ctx* device); uint8_t aciodrv_device_get_node_count(struct aciodrv_device_ctx *device);
/** /**
* Get the product identifier of an enumerated node. * Get the product identifier of an enumerated node.
@@ -35,7 +35,7 @@ uint8_t aciodrv_device_get_node_count(struct aciodrv_device_ctx* device);
* @return True on success, false on error. If True the variable product * @return True on success, false on error. If True the variable product
* contains the identifier of the queried node. * contains the identifier of the queried node.
*/ */
bool aciodrv_device_get_node_product_ident(struct aciodrv_device_ctx* device, uint8_t node_id, char product[4]); bool aciodrv_device_get_node_product_ident(struct aciodrv_device_ctx *device, uint8_t node_id, char product[4]);
/** /**
* Send a message to the ACIO bus and receive an answer. * Send a message to the ACIO bus and receive an answer.
@@ -48,13 +48,13 @@ bool aciodrv_device_get_node_product_ident(struct aciodrv_device_ctx* device, ui
* @param resp_size Size of the expecting response. * @param resp_size Size of the expecting response.
* @return True on success, false on error. * @return True on success, false on error.
*/ */
bool aciodrv_send_and_recv(struct aciodrv_device_ctx* device, struct ac_io_message *msg, int max_resp_size); bool aciodrv_send_and_recv(struct aciodrv_device_ctx *device, struct ac_io_message *msg, int max_resp_size);
/** /**
* Close the previously opened ACIO device. * Close the previously opened ACIO device.
* *
* @param device Context of opened device * @param device Context of opened device
*/ */
void aciodrv_device_close(struct aciodrv_device_ctx* device); void aciodrv_device_close(struct aciodrv_device_ctx *device);
#endif #endif
+1 -1
View File
@@ -185,7 +185,7 @@ void iidx_io_fini(void)
Sleep(1); Sleep(1);
} }
aciodrv_device_close(); aciodrv_device_close(bio2_device_ctx);
} }
void iidx_io_ep1_set_deck_lights(uint16_t deck_lights) void iidx_io_ep1_set_deck_lights(uint16_t deck_lights)