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

Function fxInitializeTarget

tools/serial2xsbug/serial2xsbug.c:253–345  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251}
252
253int fxInitializeTarget(txSerialTool self)
254{
255 char out[64];
256
257#if 0
258 {
259 #define BAUD (115200 * 4)
260 char machine[32];
261 sprintf(machine, "\r\n<?xs#%8.8X?>", self->currentMachine->value);
262
263 fxWriteSerial(self, machine, strlen(machine));
264 // 2 bytes of length followed by 7 bytes of payload
265 uint8_t command[] = {0, 7, 8, 0, 0, (BAUD >> 24) & 255, (BAUD >> 16) & 255, (BAUD >> 8) & 255, BAUD & 255};
266 fxWriteSerial(self, command, sizeof(command));
267 tcdrain(CFSocketGetNative(self->serialSocket));
268 usleep(200000); //@@ why?
269 speed_t speed = BAUD;
270 if (-1 == ioctl(CFSocketGetNative(self->serialSocket), IOSSIOSPEED, &speed))
271 fprintf(stderr, "set speed failed\n");
272 }
273#endif
274
275 fxSetTime(self, self->currentMachine);
276
277 if (gPrefs) {
278 fxSetPref(self);
279 return 0;
280 }
281
282 if (!gCmd) {
283 if (!gModuleName)
284 return 0;
285 gCmd = "load";
286 }
287
288 // run command
289 if (!strcmp("uninstall", gCmd)) {
290 if (self->traceCommands)
291 fprintf(stderr, "### uninstall\n");
292
293 sprintf(out, "\r\n<?xs#%8.8X?>", self->currentMachine->value);
294 fxWriteSerial(self, out, strlen(out));
295
296 out[0] = 0;
297 out[1] = 3; // length
298 out[2] = 2; // uninstall cmd
299 out[3] = 0xff;
300 out[4] = 2;
301 fxWriteSerial(self, out, out[1] + 2);
302 }
303 else if (!strcmp("install", gCmd)) {
304 if (self->traceCommands)
305 fprintf(stderr, "### install\n");
306 else
307 fprintf(stderr, "Installing mod.");
308 gInstallOffset = 0;
309
310 sprintf(out, "\r\n<?xs#%8.8X?>", self->currentMachine->value);

Callers 1

fxReadSerialBufferFunction · 0.85

Calls 3

fxSetTimeFunction · 0.85
fxSetPrefFunction · 0.85
fxWriteSerialFunction · 0.70

Tested by

no test coverage detected