| 1 | /* |
| 2 | * Copyright 2020 Jan Schmidt |
| 3 | * SPDX-License-Identifier: BSL-1.0 |
| 4 | * |
| 5 | * OpenHMD - Free and Open Source API and drivers for immersive technology. |
| 6 | */ |
| 7 | /*! |
| 8 | * @file |
| 9 | * @brief Oculus Rift S HMD Radio management |
| 10 | * |
| 11 | * Functions for serialising requests to communicate with |
| 12 | * Touch controllers over the HMDs wireless radio link, |
| 13 | * collecting responses and delivering them back via callbacks. |
| 14 | * |
| 15 | * Ported from OpenHMD |
| 16 | * |
| 17 | * @author Jan Schmidt <[email protected]> |
| 18 | */ |
| 19 | #include <stdlib.h> |
| 20 | #include <string.h> |
| 21 | #include <stdio.h> |
| 22 | #include <assert.h> |
| 23 | |
| 24 | #include "util/u_misc.h"cxx . . $ `<file>/src/xrt/auxiliary/util/u_misc.h`/ |
| 25 | #include "rift_s.h"cxx . . $ `<file>/src/xrt/drivers/rift_s/rift_s.h`/ |
| 26 | #include "rift_s_radio.h"cxx . . $ `<file>/src/xrt/drivers/rift_s/rift_s_radio.h`/ |
| 27 | #include "rift_s_protocol.h"cxx . . $ `<file>/src/xrt/drivers/rift_s/rift_s_protocol.h`/ |
| 28 | |
| 29 | /* Struct that forms a double linked queue of pending commands, |
| 30 | * with the head being the currently active command */ |
| 31 | struct rift_s_radio_commandcxx . . $ rift_s_radio_command# |
| 32 | { |
| 33 | rift_s_radio_commandcxx . . $ rift_s_radio_command# *prevcxx . . $ rift_s_radio_command#prev.; |
| 34 | rift_s_radio_commandcxx . . $ rift_s_radio_command# *nextcxx . . $ rift_s_radio_command#next.; |
| 35 | |
| 36 | /* Request packet data */ |
| 37 | rift_s_hmd_radio_command_tcxx . . $ rift_s_hmd_radio_command_t# read_commandcxx . . $ rift_s_radio_command#read_command.; |
| 38 | |
| 39 | /* Completion callback */ |
| 40 | rift_s_radio_completion_fncxx . . $ rift_s_radio_completion_fn# cbcxx . . $ rift_s_radio_command#cb.; |
| 41 | void *cb_datacxx . . $ rift_s_radio_command#cb_data.; |
| 42 | }; |
| 43 | |
| 44 | static int |
| 45 | get_radio_response_reportcxx . . $ get_radio_response_report(6b916e84725d4a95).(struct os_hid_devicecxx . . $ os_hid_device# *hid, rift_s_hmd_radio_response_tcxx . . $ rift_s_hmd_radio_response_t# *radio_response) |
| 46 | { |
| 47 | int ret; |
| 48 | |
| 49 | radio_response->cmdcxx . . $ $anonymous_type_31a89a23c57bba2c_14#cmd. = 0xb; |
| 50 | ret = os_hid_get_featurecxx . . $ os_hid_get_feature(8f0b16ae4dbada59).(hid, radio_response->cmdcxx . . $ $anonymous_type_31a89a23c57bba2c_14#cmd., (uint8_tcxx . . $ uint8_t# *)(radio_response), |
| 51 | sizeof(rift_s_hmd_radio_response_tcxx . . $ rift_s_hmd_radio_response_t#)); |
| 52 | |
| 53 | return ret; |
| 54 | } |
| 55 | |
| 56 | void |
| 57 | rift_s_radio_updatecxx . . $ rift_s_radio_update(470e9c2ce7f5a561).(rift_s_radio_statecxx . . $ rift_s_radio_state# *state, struct os_hid_devicecxx . . $ os_hid_device# *hid) |
| 58 | { |
| 59 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! read_another = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 60 | |
| 61 | do { |
| 62 | /* Send a radio command if there is none active and some pending */ |
| 63 | if (state->command_result_pendingcxx . . $ rift_s_radio_state#command_result_pending. == falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`! && state->pending_commandscxx . . $ rift_s_radio_state#pending_commands.) { |
| 64 | rift_s_radio_commandcxx . . $ rift_s_radio_command# *cmd = state->pending_commandscxx . . $ rift_s_radio_state#pending_commands.; |
| 65 | rift_s_hmd_radio_command_tcxx . . $ rift_s_hmd_radio_command_t# *pkt = &cmd->read_commandcxx . . $ rift_s_radio_command#read_command.; |
| 66 | |
| 67 | pkt->cmdcxx . . $ $anonymous_type_31a89a23c57bba2c_15#cmd. = 0x12; |
| 68 | os_hid_set_featurecxx . . $ os_hid_set_feature(a6d13eeb0f6903ee).(hid, (uint8_tcxx . . $ uint8_t# *)pkt, sizeof(*pkt)); |
| 69 | // rift_s_hexdump_buffer ("ControllerFWSend", (unsigned char *)(pkt), sizeof(*pkt)); |
| 70 | state->command_result_pendingcxx . . $ rift_s_radio_state#command_result_pending. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 71 | } |
| 72 | |
| 73 | if (!state->command_result_pendingcxx . . $ rift_s_radio_state#command_result_pending.) |
| 74 | break; /* Nothing to do right now */ |
| 75 | |
| 76 | /* There's a command result pending, poll the radio response until it's complete */ |
| 77 | rift_s_hmd_radio_response_tcxx . . $ rift_s_hmd_radio_response_t# radio_response; |
| 78 | |
| 79 | /* The radio response is ready when the busy flag has cleared, and the seqnum |
| 80 | * has incremented */ |
| 81 | int ret = get_radio_response_reportcxx . . $ get_radio_response_report(6b916e84725d4a95).(hid, &radio_response); |
| 82 | |
| 83 | if (ret < 2) { |
| 84 | break; /* HID read failed - bail */ |
| 85 | } |
| 86 | |
| 87 | if (radio_response.busy_flagcxx . . $ $anonymous_type_31a89a23c57bba2c_14#busy_flag. != 0x00 || radio_response.seqnumcxx . . $ $anonymous_type_31a89a23c57bba2c_14#seqnum. == state->last_radio_seqnumcxx . . $ rift_s_radio_state#last_radio_seqnum.) { |
| 88 | if (radio_response.busy_flagcxx . . $ $anonymous_type_31a89a23c57bba2c_14#busy_flag.) |
| 89 | state->last_radio_seqnumcxx . . $ rift_s_radio_state#last_radio_seqnum. = radio_response.seqnumcxx . . $ $anonymous_type_31a89a23c57bba2c_14#seqnum.; |
| 90 | return; |
| 91 | } |
| 92 | state->last_radio_seqnumcxx . . $ rift_s_radio_state#last_radio_seqnum. = radio_response.seqnumcxx . . $ $anonymous_type_31a89a23c57bba2c_14#seqnum.; |
| 93 | |
| 94 | /* We have the controller response! */ |
| 95 | assertcxx . . $ `/usr/include/assert.h:118:11`!(ret > 3 && ret <= (int)sizeof(radio_response)); |
| 96 | |
| 97 | state->command_result_pendingcxx . . $ rift_s_radio_state#command_result_pending. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 98 | // rift_s_hexdump_buffer ("ControllerFWReply", (unsigned char *)(&radio_response), ret); |
| 99 | |
| 100 | assertcxx . . $ `/usr/include/assert.h:118:11`!(state->pending_commands != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 101 | |
| 102 | rift_s_radio_commandcxx . . $ rift_s_radio_command# *cmd = state->pending_commandscxx . . $ rift_s_radio_state#pending_commands.; |
| 103 | |
| 104 | /* Pop the head off the cmds queue, because it's complete now */ |
| 105 | state->pending_commandscxx . . $ rift_s_radio_state#pending_commands. = cmd->nextcxx . . $ rift_s_radio_command#next.; |
| 106 | if (state->pending_commandscxx . . $ rift_s_radio_state#pending_commands. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 107 | state->pending_commands_tailcxx . . $ rift_s_radio_state#pending_commands_tail. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 108 | else |
| 109 | state->pending_commandscxx . . $ rift_s_radio_state#pending_commands.->prevcxx . . $ rift_s_radio_command#prev. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 110 | |
| 111 | /* Call the completion callback */ |
| 112 | if (cmd->cbcxx . . $ rift_s_radio_command#cb.) |
| 113 | cmd->cbcxx . . $ rift_s_radio_command#cb.(truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, radio_response.response_bytescxx . . $ $anonymous_type_31a89a23c57bba2c_14#response_bytes., ret - 3, cmd->cb_datacxx . . $ rift_s_radio_command#cb_data.); |
| 114 | freecxx . . $ free(5d22bdacc48458e8).(cmd); |
| 115 | read_another = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 116 | |
| 117 | } while (read_another); |
| 118 | } |
| 119 | |
| 120 | void |
| 121 | rift_s_radio_state_initcxx . . $ rift_s_radio_state_init(f1bfd682f7e0b315).(rift_s_radio_statecxx . . $ rift_s_radio_state# *state) |
| 122 | { |
| 123 | state->command_result_pendingcxx . . $ rift_s_radio_state#command_result_pending. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 124 | state->pending_commandscxx . . $ rift_s_radio_state#pending_commands. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 125 | state->pending_commands_tailcxx . . $ rift_s_radio_state#pending_commands_tail. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 126 | state->last_radio_seqnumcxx . . $ rift_s_radio_state#last_radio_seqnum. = -1; |
| 127 | } |
| 128 | |
| 129 | void |
| 130 | rift_s_radio_state_clearcxx . . $ rift_s_radio_state_clear(f1bfd682f7e0b315).(rift_s_radio_statecxx . . $ rift_s_radio_state# *state) |
| 131 | { |
| 132 | /* Clear and free any pending commands. */ |
| 133 | rift_s_radio_commandcxx . . $ rift_s_radio_command# *head = state->pending_commandscxx . . $ rift_s_radio_state#pending_commands.; |
| 134 | while (head != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 135 | rift_s_radio_commandcxx . . $ rift_s_radio_command# *prev = head; |
| 136 | head = prev->nextcxx . . $ rift_s_radio_command#next.; |
| 137 | |
| 138 | if (prev->cbcxx . . $ rift_s_radio_command#cb.) |
| 139 | prev->cbcxx . . $ rift_s_radio_command#cb.(falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, prev->cb_datacxx . . $ rift_s_radio_command#cb_data.); |
| 140 | freecxx . . $ free(5d22bdacc48458e8).(prev); |
| 141 | } |
| 142 | |
| 143 | state->pending_commandscxx . . $ rift_s_radio_state#pending_commands. = state->pending_commands_tailcxx . . $ rift_s_radio_state#pending_commands_tail. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 144 | } |
| 145 | |
| 146 | void |
| 147 | rift_s_radio_queue_commandcxx . . $ rift_s_radio_queue_command(79c73fdd53fafac7).(rift_s_radio_statecxx . . $ rift_s_radio_state# *state, |
| 148 | const uint64_tcxx . . $ uint64_t# device_id, |
| 149 | const uint8_tcxx . . $ uint8_t# *cmd_bytes, |
| 150 | const int cmd_bytes_len, |
| 151 | rift_s_radio_completion_fncxx . . $ rift_s_radio_completion_fn# cb, |
| 152 | void *cb_data) |
| 153 | { |
| 154 | rift_s_radio_commandcxx . . $ rift_s_radio_command# *cmd = U_TYPED_CALLOCcxx . . $ `src/xrt/auxiliary/util/u_misc.h:47:9`!(rift_s_radio_command); |
| 155 | |
| 156 | assertcxx . . $ `/usr/include/assert.h:118:11`!(cmd_bytes_len <= (int)sizeof(cmd->read_command.cmd_bytes)); |
| 157 | |
| 158 | cmd->read_commandcxx . . $ rift_s_radio_command#read_command..device_idcxx . . $ $anonymous_type_31a89a23c57bba2c_15#device_id. = device_id; |
| 159 | memcpycxx . . $ memcpy(cc817cb175f282d).(cmd->read_commandcxx . . $ rift_s_radio_command#read_command..cmd_bytescxx . . $ $anonymous_type_31a89a23c57bba2c_15#cmd_bytes., cmd_bytes, cmd_bytes_len); |
| 160 | cmd->cbcxx . . $ rift_s_radio_command#cb. = cb; |
| 161 | cmd->cb_datacxx . . $ rift_s_radio_command#cb_data. = cb_data; |
| 162 | |
| 163 | /* Append to the pending commands queue. The command itself will be sent by the update() function |
| 164 | * when possible */ |
| 165 | if (state->pending_commands_tailcxx . . $ rift_s_radio_state#pending_commands_tail. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 166 | assertcxx . . $ `/usr/include/assert.h:118:11`!(state->pending_commands == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 167 | state->pending_commandscxx . . $ rift_s_radio_state#pending_commands. = state->pending_commands_tailcxx . . $ rift_s_radio_state#pending_commands_tail. = cmd; |
| 168 | } else { |
| 169 | state->pending_commands_tailcxx . . $ rift_s_radio_state#pending_commands_tail.->nextcxx . . $ rift_s_radio_command#next. = cmd; |
| 170 | cmd->prevcxx . . $ rift_s_radio_command#prev. = state->pending_commands_tailcxx . . $ rift_s_radio_state#pending_commands_tail.; |
| 171 | state->pending_commands_tailcxx . . $ rift_s_radio_state#pending_commands_tail. = cmd; |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | /* The current blocks are ~2-3KB, so this should be enough to read |
| 176 | * the JSON config: */ |
| 177 | #define MAX_JSON_LENcxx . . $ `src/xrt/drivers/rift_s/rift_s_radio.c:177:9`! 4096 |
| 178 | |
| 179 | typedef struct rift_s_radio_json_read_statecxx . . $ rift_s_radio_json_read_state# |
| 180 | { |
| 181 | rift_s_radio_statecxx . . $ rift_s_radio_state# *statecxx . . $ rift_s_radio_json_read_state#state.; |
| 182 | uint64_tcxx . . $ uint64_t# device_idcxx . . $ rift_s_radio_json_read_state#device_id.; |
| 183 | rift_s_radio_completion_fncxx . . $ rift_s_radio_completion_fn# cbcxx . . $ rift_s_radio_json_read_state#cb.; |
| 184 | void *cb_datacxx . . $ rift_s_radio_json_read_state#cb_data.; |
| 185 | |
| 186 | uint32_tcxx . . $ uint32_t# cur_offsetcxx . . $ rift_s_radio_json_read_state#cur_offset.; |
| 187 | uint16_tcxx . . $ uint16_t# block_lencxx . . $ rift_s_radio_json_read_state#block_len.; /* Expected length, from the header */ |
| 188 | |
| 189 | uint8_tcxx . . $ uint8_t# datacxx . . $ rift_s_radio_json_read_state#data.[MAX_JSON_LENcxx . . $ `src/xrt/drivers/rift_s/rift_s_radio.c:177:9`! + 1]; |
| 190 | uint16_tcxx . . $ uint16_t# data_lencxx . . $ rift_s_radio_json_read_state#data_len.; |
| 191 | |
| 192 | } rift_s_radio_json_read_statecxx . . $ rift_s_radio_json_read_state#; |
| 193 | |
| 194 | static void |
| 195 | read_json_cbcxx . . $ read_json_cb(fca5bb0425c6dfa8).(boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! success, uint8_tcxx . . $ uint8_t# *response_bytes, int response_bytes_len, rift_s_radio_json_read_statecxx . . $ rift_s_radio_json_read_state# *json_read) |
| 196 | { |
| 197 | if (!success) { |
| 198 | /* Failed, report to the caller */ |
| 199 | goto fail; |
| 200 | } |
| 201 | |
| 202 | if (response_bytes_len < 5) { |
| 203 | RIFT_S_WARNcxx . . $ `src/xrt/drivers/rift_s/rift_s.h:45:9`!("Not enough bytes in radio response - needed 5, got %d\n", response_bytes_len); |
| 204 | goto fail; |
| 205 | } |
| 206 | |
| 207 | uint8_tcxx . . $ uint8_t# reply_len = response_bytes[4]; |
| 208 | response_bytes += 5; |
| 209 | |
| 210 | if (json_read->cur_offsetcxx . . $ rift_s_radio_json_read_state#cur_offset. == 0) { |
| 211 | /* Read the header 0u32 0x20 01 00 62 09 7b 22 67 79 | .{..... ..b.{"gy |
| 212 | 72 6f 5f 6d 22 3a 5b 2d 30 2e 30 31 34 33 35 36 | ro_m":[-0.014356 |
| 213 | 38 38 36 36 2c 2d 30 2e | 8866,-0. |
| 214 | = len 0x20, 0001 (file type, or sequence number?), 0x0962 = file length */ |
| 215 | if (reply_len < 4) { |
| 216 | RIFT_S_WARNcxx . . $ `src/xrt/drivers/rift_s/rift_s.h:45:9`!("Not enough bytes in remote configuration header - needed 4, got %d\n", reply_len); |
| 217 | goto fail; /* Not enough bytes in header */ |
| 218 | } |
| 219 | |
| 220 | uint16_tcxx . . $ uint16_t# file_type = (response_bytes[1] << 8) | response_bytes[0]; |
| 221 | uint16_tcxx . . $ uint16_t# block_len = (response_bytes[3] << 8) | response_bytes[2]; |
| 222 | |
| 223 | if (file_type != 1) { |
| 224 | RIFT_S_WARNcxx . . $ `src/xrt/drivers/rift_s/rift_s.h:45:9`!("Unknown file type in remote configuration header - expected 1, got %d\n", |
| 225 | file_type); |
| 226 | goto fail; |
| 227 | } |
| 228 | /* Assert if the MAX_JSON_LEN ever needs expanding */ |
| 229 | assertcxx . . $ `/usr/include/assert.h:118:11`!(block_len <= MAX_JSON_LENcxx . . $ `src/xrt/drivers/rift_s/rift_s_radio.c:177:9`!); |
| 230 | if (block_len > MAX_JSON_LENcxx . . $ `src/xrt/drivers/rift_s/rift_s_radio.c:177:9`!) { |
| 231 | RIFT_S_WARNcxx . . $ `src/xrt/drivers/rift_s/rift_s.h:45:9`!( |
| 232 | "Remote configuration block too long. Please expand the read buffer (needed %u bytes)\n", |
| 233 | block_len); |
| 234 | goto fail; |
| 235 | } |
| 236 | |
| 237 | json_read->block_lencxx . . $ rift_s_radio_json_read_state#block_len. = block_len; |
| 238 | json_read->cur_offsetcxx . . $ rift_s_radio_json_read_state#cur_offset. = 0x4; |
| 239 | } else { |
| 240 | uint16_tcxx . . $ uint16_t# data_remain = json_read->block_lencxx . . $ rift_s_radio_json_read_state#block_len. - json_read->data_lencxx . . $ rift_s_radio_json_read_state#data_len.; |
| 241 | |
| 242 | if (reply_len > data_remain) |
| 243 | reply_len = data_remain; /* Truncate any over-read */ |
| 244 | |
| 245 | /* Append these bytes to the buffer */ |
| 246 | memcpycxx . . $ memcpy(cc817cb175f282d).(json_read->datacxx . . $ rift_s_radio_json_read_state#data. + json_read->data_lencxx . . $ rift_s_radio_json_read_state#data_len., response_bytes, reply_len); |
| 247 | json_read->data_lencxx . . $ rift_s_radio_json_read_state#data_len. += reply_len; |
| 248 | } |
| 249 | |
| 250 | /* If there is no more to read, then report success to the caller and return */ |
| 251 | if (json_read->data_lencxx . . $ rift_s_radio_json_read_state#data_len. >= json_read->block_lencxx . . $ rift_s_radio_json_read_state#block_len.) { |
| 252 | json_read->datacxx . . $ rift_s_radio_json_read_state#data.[json_read->data_lencxx . . $ rift_s_radio_json_read_state#data_len.] = 0; |
| 253 | |
| 254 | if (json_read->cbcxx . . $ rift_s_radio_json_read_state#cb.) |
| 255 | json_read->cbcxx . . $ rift_s_radio_json_read_state#cb.(truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!, json_read->datacxx . . $ rift_s_radio_json_read_state#data., json_read->data_lencxx . . $ rift_s_radio_json_read_state#data_len., json_read->cb_datacxx . . $ rift_s_radio_json_read_state#cb_data.); |
| 256 | freecxx . . $ free(5d22bdacc48458e8).(json_read); |
| 257 | return; |
| 258 | } |
| 259 | |
| 260 | /* Otherwise request more data */ |
| 261 | uint8_tcxx . . $ uint8_t# read_len = MINcxx . . $ `src/xrt/auxiliary/math/m_api.h:59:9`!(0x20, json_read->block_len - json_read->data_len); |
| 262 | uint8_tcxx . . $ uint8_t# read_cmd[] = {0x2b, 0x20, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00}; |
| 263 | |
| 264 | read_cmd[4] = json_read->cur_offsetcxx . . $ rift_s_radio_json_read_state#cur_offset.; |
| 265 | read_cmd[5] = json_read->cur_offsetcxx . . $ rift_s_radio_json_read_state#cur_offset. >> 8; |
| 266 | read_cmd[6] = json_read->cur_offsetcxx . . $ rift_s_radio_json_read_state#cur_offset. >> 16; |
| 267 | read_cmd[7] = json_read->cur_offsetcxx . . $ rift_s_radio_json_read_state#cur_offset. >> 24; |
| 268 | read_cmd[8] = read_len; |
| 269 | |
| 270 | rift_s_radio_queue_commandcxx . . $ rift_s_radio_queue_command(79c73fdd53fafac7).(json_read->statecxx . . $ rift_s_radio_json_read_state#state., json_read->device_idcxx . . $ rift_s_radio_json_read_state#device_id., read_cmd, sizeof(read_cmd), |
| 271 | (rift_s_radio_completion_fncxx . . $ rift_s_radio_completion_fn#)read_json_cbcxx . . $ read_json_cb(fca5bb0425c6dfa8)., json_read); |
| 272 | |
| 273 | json_read->cur_offsetcxx . . $ rift_s_radio_json_read_state#cur_offset. += read_len; |
| 274 | return; |
| 275 | |
| 276 | fail: |
| 277 | if (json_read->cbcxx . . $ rift_s_radio_json_read_state#cb.) |
| 278 | json_read->cbcxx . . $ rift_s_radio_json_read_state#cb.(success, json_read->datacxx . . $ rift_s_radio_json_read_state#data., json_read->data_lencxx . . $ rift_s_radio_json_read_state#data_len., json_read->cb_datacxx . . $ rift_s_radio_json_read_state#cb_data.); |
| 279 | freecxx . . $ free(5d22bdacc48458e8).(json_read); |
| 280 | return; |
| 281 | } |
| 282 | |
| 283 | void |
| 284 | rift_s_radio_get_json_blockcxx . . $ rift_s_radio_get_json_block(b8a87017a7bda3c4).(rift_s_radio_statecxx . . $ rift_s_radio_state# *state, |
| 285 | const uint64_tcxx . . $ uint64_t# device_id, |
| 286 | rift_s_radio_completion_fncxx . . $ rift_s_radio_completion_fn# cb, |
| 287 | void *cb_data) |
| 288 | { |
| 289 | /* Configuration JSON block reading */ |
| 290 | rift_s_radio_json_read_statecxx . . $ rift_s_radio_json_read_state# *json_read = U_TYPED_CALLOCcxx . . $ `src/xrt/auxiliary/util/u_misc.h:47:9`!(rift_s_radio_json_read_state); |
| 291 | /* cmd = 0x2b reply_buffer_len = 0x20 timeout(?) = 0x3e8 (=1000) offset = 0u32 len = 0x20 */ |
| 292 | const uint8_tcxx . . $ uint8_t# read_cmd[] = {0x2b, 0x20, 0xe8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00}; |
| 293 | |
| 294 | json_read->statecxx . . $ rift_s_radio_json_read_state#state. = state; |
| 295 | json_read->device_idcxx . . $ rift_s_radio_json_read_state#device_id. = device_id; |
| 296 | json_read->cbcxx . . $ rift_s_radio_json_read_state#cb. = cb; |
| 297 | json_read->cb_datacxx . . $ rift_s_radio_json_read_state#cb_data. = cb_data; |
| 298 | |
| 299 | rift_s_radio_queue_commandcxx . . $ rift_s_radio_queue_command(79c73fdd53fafac7).(state, device_id, read_cmd, sizeof(read_cmd), |
| 300 | (rift_s_radio_completion_fncxx . . $ rift_s_radio_completion_fn#)read_json_cbcxx . . $ read_json_cb(fca5bb0425c6dfa8)., json_read); |
| 301 | } |