33static void backend_set_verbosity(
uint8_t verbosity, FILE *output) {
38static yh_rc backend_init(
uint8_t verbosity, FILE *output) {
39 backend_set_verbosity(verbosity, output);
69static void backend_disconnect(
yh_backend *connection) {
76 unsigned long read_len;
77 msg->
st.len = htons(msg->
st.len);
79 for (
int i = 0; i <= 1; i++) {
84 DBG_ERR(
"Failed reconnecting device");
95 if (
usb_read(connection, response->raw, &read_len) == 0) {
109 DBG_ERR(
"Not enough data received; %lu", read_len);
113 response->st.len = ntohs(response->st.len);
115 if (response->st.len != read_len - 3) {
116 DBG_ERR(
"Wrong length received, %d vs %lu", response->st.len, read_len);
123static void backend_cleanup(
void) {}
131 DBG_ERR(
"Backend options not (yet?) supported for USB");
bool YH_INTERNAL parse_usb_url(const char *url, unsigned long *serial)
yh_rc(* backend_init)(uint8_t verbosity, FILE *output)
void(* backend_set_verbosity)(uint8_t verbosity, FILE *output)
void(* backend_disconnect)(yh_backend *connection)
yh_rc(* backend_send_msg)(yh_backend *connection, Msg *msg, Msg *response)
yh_rc(* backend_option)(yh_backend *connection, yh_connector_option opt, const void *val)
yh_backend *(* backend_create)(void)
void(* backend_cleanup)(void)
yh_rc(* backend_connect)(yh_connector *connector, int timeout)
uint8_t raw[3+SCP_MSG_BUF_SIZE]
@ YHR_GENERIC_ERROR
Return value when encountering an unknown error.
@ YHR_SUCCESS
Returned value when function was successful.
@ YHR_CONNECTOR_ERROR
Return value when connector operation failed.
@ YHR_CONNECTION_ERROR
Returned value when a connection error was encountered.
void usb_destroy(yh_backend **state)
void usb_close(yh_backend *state)
void usb_set_serial(yh_backend *state, unsigned long serial)
int usb_read(yh_backend *state, unsigned char *buf, unsigned long *len)
bool usb_open_device(yh_backend *backend)
int usb_write(yh_backend *state, unsigned char *buf, long unsigned len)
FILE YH_INTERNAL * _yh_output
struct backend_functions * backend_functions(void)
uint8_t YH_INTERNAL _yh_verbosity