fixes in bulk write and add example of writing INI via TF

This commit is contained in:
2017-12-24 23:17:33 +01:00
parent 414f8859eb
commit 96b1e11e55
4 changed files with 12 additions and 6 deletions
+2 -2
View File
@@ -121,7 +121,7 @@ bool GEX_BulkWrite(GexUnit *unit, GexBulk *bulk)
if (max_size < bulk->len) {
fprintf(stderr, "Write not possible, not enough space.\n");
// Inform GEX we're not going to do it
GEX_SendEx(unit, MSG_BULK_ABORT, NULL, 0, resp0.session, true);
GEX_SendEx(unit, MSG_BULK_ABORT, NULL, 0, resp0.session, true, true);
return false;
}
@@ -145,7 +145,7 @@ bool GEX_BulkWrite(GexUnit *unit, GexBulk *bulk)
}
// Conclude the transfer
GEX_SendEx(unit, MSG_BULK_END, NULL, 0, resp0.session, true);
GEX_SendEx(unit, MSG_BULK_END, NULL, 0, resp0.session, true, true);
return true;
}
+2 -2
View File
@@ -86,12 +86,12 @@ void GEX_Send(GexUnit *unit, uint8_t cmd, const uint8_t *payload, uint32_t len)
/** Send with no listener, don't wait for response */
void GEX_SendEx(GexUnit *unit, uint8_t cmd,
const uint8_t *payload, uint32_t len,
GexSession session, bool is_reply)
GexSession session, bool is_reply, bool raw_pld)
{
assert(unit != NULL);
assert(unit->gex != NULL);
GEX_LL_Query(unit, cmd, payload, len, session, is_reply, NULL, NULL, false);
GEX_LL_Query(unit, cmd, payload, len, session, is_reply, NULL, NULL, raw_pld);
}
/** listener for the synchronous query functionality */
+2 -1
View File
@@ -65,6 +65,7 @@ GexMsg GEX_QueryEx(GexUnit *unit, uint8_t cmd,
void GEX_SendEx(GexUnit *unit, uint8_t cmd,
const uint8_t *payload, uint32_t len,
GexSession session, bool is_reply);
GexSession session, bool is_reply,
bool raw_pld);
#endif //GEX_CLIENT_GEX_UNIT_H
+6 -1
View File
@@ -99,7 +99,7 @@ int main(void)
#endif
#if 1
// Read the communist manifesto via bulk transfer
// Load settings to a buffer as INI
uint8_t inifile[10000];
br = (GexBulk){
.buffer = inifile,
@@ -111,6 +111,11 @@ int main(void)
uint32_t actuallyRead = GEX_BulkRead(GEX_SystemUnit(gex), &br);
fprintf(stderr, "Read %d bytes of INI:\n", actuallyRead);
fprintf(stderr, "%.*s", actuallyRead, inifile);
// And send it back...
br.len = actuallyRead;
br.req_cmd = MSG_INI_WRITE;
GEX_BulkWrite(GEX_SystemUnit(gex), &br);
#endif
#if 0