updated tinyframe and finished bulk write

master
Ondřej Hruška 7 years ago
parent e82d45eefb
commit bfe625b644
  1. 7
      gex/gex_bulk.c
  2. 2
      gex/protocol/TinyFrame.c
  3. 2
      gex/protocol/TinyFrame.h
  4. 34
      main.c

@ -94,6 +94,9 @@ uint32_t GEX_BulkRead(GexUnit *unit, GexBulk *bulk)
*/
bool GEX_BulkWrite(GexUnit *unit, GexBulk *bulk)
{
fprintf(stderr, "Asking for bulk write...\n");
// We ask for the transfer. This is unit specific
GexMsg resp0 = GEX_Query(unit, bulk->req_cmd, bulk->req_data, bulk->req_len);
@ -112,6 +115,8 @@ bool GEX_BulkWrite(GexUnit *unit, GexBulk *bulk)
uint32_t max_chunk = pp_u32(&pp);
assert(pp.ok);
fprintf(stderr, "Write allowed, size %d, chunk %d\n", (int)max_size, (int)max_chunk);
if (max_size < bulk->len) {
fprintf(stderr, "Write not possible, not enough space.\n");
// Inform GEX we're not going to do it
@ -122,7 +127,7 @@ bool GEX_BulkWrite(GexUnit *unit, GexBulk *bulk)
uint32_t at = 0;
while (at < bulk->len) {
uint32_t chunk = MIN(max_chunk, bulk->len - at);
// fprintf(stderr, "Query at %d, len %d\n", (int)at, (int)chunk);
fprintf(stderr, "Query at %d, len %d\n", (int)at, (int)chunk);
GexMsg resp = GEX_QueryEx(unit, MSG_BULK_DATA, bulk->buffer + at, chunk,
resp0.session, true, true);
at += chunk;

@ -549,7 +549,7 @@ void _TF_FN TF_AcceptChar(TinyFrame *tf, unsigned char c)
CKSUM_RESET(tf->cksum); // Start collecting the payload
if (tf->len >= TF_MAX_PAYLOAD_RX) {
if (tf->len > TF_MAX_PAYLOAD_RX) {
// ERROR - frame too long. Consume, but do not store.
tf->discard_data = true;
}

@ -10,7 +10,7 @@
* Upstream URL: https://github.com/MightyPork/TinyFrame
*/
#define TF_VERSION "2.0.3"
#define TF_VERSION "2.0.4"
//---------------------------------------------------------------------------
#include <stdint.h> // for uint8_t etc

@ -30,8 +30,24 @@ TF_Result hdl_default(TinyFrame *tf, TF_Msg*msg)
return TF_STAY;
}
const char *longtext = "A sharper perspective on this matter is particularly important to feminist\r\n"
"thought today, because a major tendency in feminism has constructed the\r\n"
"problem of domination as a drama of female vulnerability victimized by male\r\n"
"aggression. Even the more sophisticated feminist thinkers frequently shy\r\n"
"away from the analysis of submission, for fear that in admitting woman's\r\n"
"participation in the relationship of domination, the onus of responsibility\r\n"
"will appear to shift from men to women, and the moral victory from women to\r\n"
"men. More generally, this has been a weakness of radical politics: to\r\n"
"idealize the oppressed, as if their politics and culture were untouched by\r\n"
"the system of domination, as if people did not participate in their own\r\n"
"submission. To reduce domination to a simple relation of doer and done-to\r\n"
"is to substitute moral outrage for analysis.\r\n"
"\t\t-- Jessica Benjamin, \"The Bonds of Love\"";
int main(void)
{
GexBulk br;
// Bind ^C handler for safe shutdown
signal(SIGINT, sigintHandler);
@ -56,7 +72,7 @@ int main(void)
fprintf(stderr, "Cmd \"PING\" OK\n");
#endif
#if 1
#if 0
// Test a echo command that returns back what was sent to it as useful payload
const char *s = "I am \r\nreturning this otherwise good typing paper to you because someone "
"has printed gibberish all over it and put your name at the top. Read the communist manifesto via bulk transfer. Read the communist manifesto via bulk transfer. Technology is a constand battle between manufacturers producing bigger and "
@ -66,10 +82,10 @@ int main(void)
assert(0==strncmp((char*)msg.payload, s, strlen(s)));
#endif
#if 1
#if 0
// Read the communist manifesto via bulk transfer
uint8_t buffr[10000];
GexBulk br = {
br = {
.buffer = buffr,
.capacity = 10000,
.req_cmd = 2,
@ -81,6 +97,18 @@ int main(void)
fprintf(stderr, "%.*s", actuallyRead, buffr);
#endif
#if 1
// Read the communist manifesto via bulk transfer
br = (GexBulk){
.buffer = (uint8_t *) longtext,
.len = (uint32_t) strlen(longtext),
.req_cmd = 3,
.req_data = NULL,
.req_len = 0,
};
assert(true == GEX_BulkWrite(test, &br));
#endif
fprintf(stderr, "\n\nALL done, ending.\n");
GEX_DeInit(gex);
return 0;

Loading…
Cancel
Save