MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxSetPref

Function fxSetPref

tools/serial2xsbug/serial2xsbug.c:895–922  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

893}
894
895void fxSetPref(txSerialTool self)
896{
897 char preamble[32];
898 char out[5];
899 Pref p = gPrefs;
900 if (!p) return;
901
902 gPrefs = p->next;
903
904 if (self->traceCommands)
905 fprintf(stderr, "### set preference %s.%s=%s\n", p->domain, p->name, p->value);
906
907 sprintf(preamble, "\r\n<?xs#%8.8X?>", self->currentMachine->value);
908 fxWriteSerial(self, preamble, strlen(preamble));
909
910 int size = strlen(p->domain) + 1 + strlen(p->name) + 1 + 1 + strlen(p->value);
911 size += 3;
912 out[0] = (size >> 8) & 0xff; // length high
913 out[1] = size & 0xff; // length low
914 out[2] = 4; // set preference cmd
915 out[3] = 0xff; // id high
916 out[4] = 0x03; // id low
917 fxWriteSerial(self, out, 5);
918 fxWriteSerial(self, p->domain, strlen(p->domain) + 1);
919 fxWriteSerial(self, p->name, strlen(p->name) + 1);
920 fxWriteSerial(self, &p->kind, 1);
921 fxWriteSerial(self, p->value, strlen(p->value));
922}

Callers 2

fxInitializeTargetFunction · 0.85
fxCommandReceivedFunction · 0.85

Calls 1

fxWriteSerialFunction · 0.70

Tested by

no test coverage detected