/*-------------------------------------------------- ComMode_Data() 主机接收到编码1信号后,会反馈一个编码1信号给附机 以表示主机在附机附近。 ---------------------------------------------------*/ void ComMode_Data(tByte ComMode, x) { receiver_EN = 1; Delay(20); transmiter_EN = 0; myTxRxData[0] = CmdHead; myTxRxData[1] = MyAddress; myTxRxData[2] = ComMode; initsignal(); Send_Data(x); transmiter_EN = 1; receiver_EN = 0; }
/*------------------------------------------------------------------ UART发送数据 ------------------------------------------------------------------*/ void UART_Send_Data(void) { receiver_EN = 1; Delay(20); transmiter_EN = 0; myTxRxData[0] = IDkey0; myTxRxData[1] = IDkey1; myTxRxData[2] = IDkey2; myTxRxData[3] = IDkey3; myTxRxData[4] = IDkey4; // myTxRxData[5] = IDkey5; initsignal(); SendNByte(myTxRxData, 6); transmiter_EN = 1; receiver_EN = 0; }
int main(int argc, char *argv[]) { char buf[BLKSIZE]; int done = 0; int error; int fd1; int fd2; /* open the file descriptors for I/O */ if (argc != 3) { fprintf(stderr, "Usage: %s filename1 filename2\n", argv[0]); return 1; } if ((fd1 = open(argv[1], O_RDONLY)) == -1) { fprintf(stderr, "Failed to open %s:%s\n", argv[1], strerror(errno)); return 1; } if ((fd2 = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC, MODE)) == -1) { fprintf(stderr, "Failed to open %s: %s\n", argv[2], strerror(errno)); return 1; } if (initsignal(SIGRTMAX) == -1) { perror("Failed to initialize signal"); return 1; } if (initread(fd1, fd2, SIGRTMAX, buf, BLKSIZE) == -1) { perror("Failed to initate the first read"); return 1; } for ( ; ; ) { dowork(); if (!done) if (done = getdone()) if (error = geterror()) fprintf(stderr, "Failed to copy file:%s\n", strerror(error)); else fprintf(stderr, "Copy successful, %d bytes\n", getbytes()); } }
void PyOS_InitInterrupts(void) { initsignal(); _PyImport_FixupExtension("signal", "signal"); }
extern int main(int argc, char *argv[], char *envp[]) { char *dashsee[2], *dollarzero, *null[1]; int c; initprint(); dashsee[0] = dashsee[1] = NULL; dollarzero = argv[0]; rc_pid = getpid(); dashell = (*argv[0] == '-'); /* Unix tradition */ while ((c = rc_getopt(argc, argv, "c:deiIlnopsvx")) != -1) switch (c) { case 'c': dashsee[0] = rc_optarg; goto quitopts; case 'd': dashdee = TRUE; break; case 'e': dashee = TRUE; break; case 'I': dashEYE = TRUE; interactive = FALSE; break; case 'i': dasheye = interactive = TRUE; break; case 'l': dashell = TRUE; break; case 'n': dashen = TRUE; break; case 'o': dashoh = TRUE; break; case 'p': dashpee = TRUE; break; case 's': dashess = TRUE; break; case 'v': dashvee = TRUE; break; case 'x': dashex = TRUE; break; case '?': exit(1); } quitopts: argv += rc_optind; /* use isatty() iff neither -i nor -I is set, and iff the input is not from a script or -c flags */ if (!dasheye && !dashEYE && dashsee[0] == NULL && (dashess || *argv == NULL)) interactive = isatty(0); if (!dashoh) { checkfd(0, rFrom); checkfd(1, rCreate); checkfd(2, rCreate); } initsignal(); inithash(); initparse(); assigndefault("ifs", " ", "\t", "\n", (void *)0); #ifdef DEFAULTPATH assigndefault("path", DEFAULTPATH, (void *)0); #endif assigndefault("pid", nprint("%d", rc_pid), (void *)0); assigndefault("prompt", "; ", "", (void *)0); assigndefault("version", VERSION, "$Release: @(#)" PACKAGE " " VERSION " " RELDATE " $", (void *)0); initenv(envp); initinput(); null[0] = NULL; starassign(dollarzero, null, FALSE); /* assign $0 to $* */ inithandler(); if (dashell) { char *rcrc; int fd; rcrc = concat(varlookup("home"), word("/.rcrc", NULL))->w; fd = rc_open(rcrc, rFrom); if (fd == -1) { if (errno != ENOENT) uerror(rcrc); } else { bool push_interactive; pushfd(fd); push_interactive = interactive; interactive = FALSE; doit(TRUE); interactive = push_interactive; close(fd); } } if (dashsee[0] != NULL || dashess) { /* input from -c or -s? */ if (*argv != NULL) starassign(dollarzero, argv, FALSE); if (dashess) pushfd(0); else pushstring(dashsee, TRUE); } else if (*argv != NULL) { /* else from a file? */ b_dot(--argv); rc_exit(getstatus()); } else { /* else stdin */ pushfd(0); } dasheye = FALSE; doit(TRUE); rc_exit(getstatus()); return 0; /* Never really reached. */ }