Implemented PINOUT.TXT file

This commit is contained in:
2018-01-07 13:04:19 +01:00
parent ad39fc280f
commit 26934a0984
15 changed files with 217 additions and 63 deletions
+12 -2
View File
@@ -80,7 +80,7 @@ static TF_Result lst_ini_export(TinyFrame *tf, TF_Msg *msg)
assert_param(bulk);
bulk->frame_id = msg->frame_id;
bulk->len = settings_get_units_ini_len();
bulk->len = iw_measure_total(settings_build_units_ini);
bulk->read = settings_bulkread_cb;
bulk->userdata = NULL;
@@ -124,7 +124,16 @@ static TF_Result lst_ini_import(TinyFrame *tf, TF_Msg *msg)
assert_param(bulk);
bulk->frame_id = msg->frame_id;
bulk->len = settings_get_units_ini_len();
// we get the total len in the payload - ini can be as long as it wants, we parse it on-line
PayloadParser pp = pp_start(msg->data, msg->len, NULL);
uint32_t len = pp_u32(&pp);
if (!pp.ok) {
com_respond_error(msg->frame_id, E_PROTOCOL_BREACH);
goto done;
}
bulk->len = len;
bulk->write = settings_bulkwrite_cb;
settings_load_ini_begin();
@@ -132,6 +141,7 @@ static TF_Result lst_ini_import(TinyFrame *tf, TF_Msg *msg)
bulkwrite_start(tf, bulk);
done:
return TF_STAY;
}
+3 -3
View File
@@ -30,7 +30,7 @@ static TF_Result bulkwrite_lst(TinyFrame *tf, TF_Msg *msg)
else if (msg->type == MSG_BULK_DATA || msg->type == MSG_BULK_END) {
// if past len, speak up
if (bulk->offset >= bulk->len) {
com_respond_error(bulk->frame_id, E_OVERRUN);
com_respond_error(bulk->frame_id, E_PROTOCOL_BREACH);
goto close;
}
@@ -71,8 +71,8 @@ void bulkwrite_start(TinyFrame *tf, BulkWrite *bulk)
{
uint8_t buf[8];
PayloadBuilder pb = pb_start(buf, 8, NULL);
pb_u32(&pb, bulk->len);
pb_u32(&pb, TF_MAX_PAYLOAD_RX);
pb_u32(&pb, bulk->len); // total expected len
pb_u32(&pb, TF_MAX_PAYLOAD_RX); // max chunk size
// We use userdata1 to hold a reference to the bulk transfer
TF_Msg msg = {