summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAditya Naik2020-08-10 15:09:35 -0400
committerAditya Naik2020-08-10 15:09:35 -0400
commit985ddbb3baa21ec391f915b1fe6fcb68d08b5148 (patch)
treef4d0594e89d9fdd2b32bf0d55798e7f2937badc2
parent1dbb8b32a44c98990e7d585819e29543bf4fd220 (diff)
Testing hs
-rw-r--r--src/master_posix.c57
1 files changed, 29 insertions, 28 deletions
diff --git a/src/master_posix.c b/src/master_posix.c
index 0d6bf82..a79df53 100644
--- a/src/master_posix.c
+++ b/src/master_posix.c
@@ -59,6 +59,8 @@ hs_func_t hs_jumptable[NUM_HS_STATES] = {
HS_STATE_TABLE(EXPAND_AS_JUMPTABLE)
};
+p_stream_t device_streams[2];
+
/* df_func_t df_jumptable[NUM_DF_STATES] = { */
/* DF_STATE_TABLE(EXPAND_AS_JUMPTABLE) */
/* }; */
@@ -110,7 +112,6 @@ bool master_encode_MDR_callback(pb_ostream_t *ostream, const pb_field_t *field,
void vStartPOSIXMaster(void *pvParams)
{
pthread_t handshake_thread, dataflow_thread, routing_thread;
- p_stream_t device_streams[2];
/* Stream initializations should be handled by the devicetree library once that's set up */
STREAM_INIT(STDIO, NULL, device_streams[0]);
@@ -163,37 +164,37 @@ static void *handshake_func(void * pvArgs)
* detect device configuration errors at compile time.
*
*/
- if (todo_hs_or_not_todo_hs(GET_ADDR_FROM_IDX(dev_idx))) {
- int hs_state = HS_STATE_0;
- void **args;
- args = malloc(sizeof(uint8_t*)*2);
-
- uint32_t dev_idx = 0; /*< Do something with this, not relevant anymore */
-
- while (hs_state != HS_STATE_FAIL && hs_state != HS_STATE_SUCCESS)
- hs_state = hs_jumptable[hs_state](stream, args);
-
- if (hs_state == HS_STATE_SUCCESS) {
- /* Attempt to decode the protobuf, and add devices */
- s2m_MDR_response MDR_res_message = s2m_MDR_response_init_default;
- MDR_res_message.subscriptions.funcs.decode = decode_subscriptions_callback;
- MDR_res_message.subscriptions.arg = (void*)dev_idx;
- pb_istream_t MDR_res_stream = pb_istream_from_buffer(args[1],
- *(uint16_t*)args[0]);
- if (!pb_decode(&MDR_res_stream, s2m_MDR_response_fields, &MDR_res_message)) {
- hs_state = HS_STATE_FAIL;
- }
- else {
- device_info[dev_idx] = malloc(sizeof(device_info_t));
- device_info[dev_idx]->i2c_addr = 0x0;
- device_info[dev_idx]->device_id = dev_idx;
+ /* if (todo_hs_or_not_todo_hs(GET_ADDR_FROM_IDX(dev_idx))) { */
+ int hs_state = HS_STATE_0;
+ void **args;
+ args = malloc(sizeof(uint8_t*)*2);
+
+ uint32_t dev_idx = 0; /*< Do something with this, not relevant anymore */
+
+ while (hs_state != HS_STATE_FAIL && hs_state != HS_STATE_SUCCESS)
+ hs_state = hs_jumptable[hs_state](stream, args);
+
+ if (hs_state == HS_STATE_SUCCESS) {
+ /* Attempt to decode the protobuf, and add devices */
+ s2m_MDR_response MDR_res_message = s2m_MDR_response_init_default;
+ MDR_res_message.subscriptions.funcs.decode = decode_subscriptions_callback;
+ MDR_res_message.subscriptions.arg = (void*)dev_idx;
+ pb_istream_t MDR_res_stream = pb_istream_from_buffer(args[1],
+ *(uint16_t*)args[0]);
+ if (!pb_decode(&MDR_res_stream, s2m_MDR_response_fields, &MDR_res_message)) {
+ hs_state = HS_STATE_FAIL;
+ }
+ else {
+ device_info[dev_idx] = malloc(sizeof(device_info_t));
+ device_info[dev_idx]->i2c_addr = 0x0;
+ device_info[dev_idx]->device_id = dev_idx;
device_info[dev_idx]->MDR = MDR_res_message;
hs_state = HS_REGISTERED;
- }
}
-
+ /* } */
+
/* TODO This is slightly redundant now, so fix this */
- dev_sts[dev_idx] = get_state_from_hs_status(GET_ADDR_FROM_IDX(dev_idx), hs_state);
+ /* dev_sts[dev_idx] = get_state_from_hs_status(GET_ADDR_FROM_IDX(dev_idx), hs_state); */
}
}
}