//_______________________________________________________________________ static int openDev (const char *name) { int dev = open (name, O_RDWR); if (dev == -1) { char str[256]; sprintf (str, "can't open device \"%s\" (errno=%d)", name, errno); FatalError (str); } SetupSerial (GetData ()); return dev; }
int main(int argc, const char *argv[]) { ParseArgs(argc, argv); if (cmdsOnly) { /* We make this a special case to avoid messing up other code. */ CreateBootCmds(); FinishBootCmds(); SendToDevice(&boot_cmds_packet->data[SIZE_OF_HEADER],SIZE_OF_BOOT_CMDS); exit(EXIT_SUCCESS); } if (netBoot && !toFiles) { /* Do not bother with this if we just want to write the packets to files. Means you do not have to be root to run --tofiles. */ net_init(); } else if (serBoot) { if (!SetupSerial()) { exit(0); } } CreateBootLoader(); CreateBootCmds(); FinishBootCmds(); printf("Starting boot...\n"); if (doing_flash) { printf("We're doing a flash write, this may take up to a few minutes...\n"); } if (toFiles) { udword seq = 0; struct packet_buf *p; while((p = create_packet(seq++))) { SendToDevice(p->data, p->size); } exit(EXIT_SUCCESS); } if (netBoot) { NetBoot(); } else if (serBoot) { SerBoot(); } printf("Done.\n"); return EXIT_SUCCESS; } /* main */
/** * Opens a serial port with the default configuration * (115200 bps, 8-N-1), using the device specified in the constructor */ int Transport::openComm(const char* device) { int tmp = OpenSerial(&(this->serial), device); if (tmp < 0) { return -1; } tmp = SetupSerial(this->serial); if (tmp < 0) { return -2; } return 0; }