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

master
Ondřej Hruška 6 years ago
parent 414f8859eb
commit 96b1e11e55
  1. 4
      gex/gex_bulk.c
  2. 4
      gex/gex_unit.c
  3. 3
      gex/gex_unit.h
  4. 7
      main.c

@ -121,7 +121,7 @@ bool GEX_BulkWrite(GexUnit *unit, GexBulk *bulk)
if (max_size < bulk->len) { if (max_size < bulk->len) {
fprintf(stderr, "Write not possible, not enough space.\n"); fprintf(stderr, "Write not possible, not enough space.\n");
// Inform GEX we're not going to do it // 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; return false;
} }
@ -145,7 +145,7 @@ bool GEX_BulkWrite(GexUnit *unit, GexBulk *bulk)
} }
// Conclude the transfer // 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; return true;
} }

@ -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 */ /** Send with no listener, don't wait for response */
void GEX_SendEx(GexUnit *unit, uint8_t cmd, void GEX_SendEx(GexUnit *unit, uint8_t cmd,
const uint8_t *payload, uint32_t len, 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 != NULL);
assert(unit->gex != 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 */ /** listener for the synchronous query functionality */

@ -65,6 +65,7 @@ GexMsg GEX_QueryEx(GexUnit *unit, uint8_t cmd,
void GEX_SendEx(GexUnit *unit, uint8_t cmd, void GEX_SendEx(GexUnit *unit, uint8_t cmd,
const uint8_t *payload, uint32_t len, 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 #endif //GEX_CLIENT_GEX_UNIT_H

@ -99,7 +99,7 @@ int main(void)
#endif #endif
#if 1 #if 1
// Read the communist manifesto via bulk transfer // Load settings to a buffer as INI
uint8_t inifile[10000]; uint8_t inifile[10000];
br = (GexBulk){ br = (GexBulk){
.buffer = inifile, .buffer = inifile,
@ -111,6 +111,11 @@ int main(void)
uint32_t actuallyRead = GEX_BulkRead(GEX_SystemUnit(gex), &br); uint32_t actuallyRead = GEX_BulkRead(GEX_SystemUnit(gex), &br);
fprintf(stderr, "Read %d bytes of INI:\n", actuallyRead); fprintf(stderr, "Read %d bytes of INI:\n", actuallyRead);
fprintf(stderr, "%.*s", actuallyRead, inifile); 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 #endif
#if 0 #if 0

Loading…
Cancel
Save