快乐虾
(QQ群:Visual EmbedLinux Tools 375515651)
欢迎转载,但请保留作者信息
本文仅适用于vs2013 + velt-0.1.5
从串口上读取字符时是这样的:
static intgetpkt_or_notif_sane_1(char **buf, long *sizeof_buf, int forever,int expecting_notif, int *is_notif){……/* Process any number of notifications, and then return whenwe get a packet. */for (;;){/* If we get a timeout or bad checksum, retry up to MAX_TRIEStimes. */for (tries = 1; tries <= MAX_TRIES; tries++){/* This can loop forever if the remote side sends uscharacters continuously, but if it pauses, we’ll getSERIAL_TIMEOUT from readchar because of timeout. Thenwe’ll count that as a retry.Note that even when forever is set, we will only waitforever prior to the start of a packet. After that, weexpect characters to arrive at a brisk pace. They shouldshow up within remote_timeout intervals. */doc = readchar(timeout);} while (c != SERIAL_TIMEOUT && c != ‘$’ && c != ‘%’);if (c == SERIAL_TIMEOUT){……}else{/* We’ve found the start of a packet or notification.Now collect the data. */val = read_frame(buf, sizeof_buf);if (val >= 0)break;}remote_serial_write("-", 1);}……}}
输出这些信息:
/* This can loop forever if the remote side sends uscharacters continuously, but if it pauses, we’ll getSERIAL_TIMEOUT from readchar because of timeout. Thenwe’ll count that as a retry.Note that even when forever is set, we will only waitforever prior to the start of a packet. After that, weexpect characters to arrive at a brisk pace. They shouldshow up within remote_timeout intervals. */do{c = readchar(timeout);if (c != SERIAL_TIMEOUT && c != ‘$’ && c != ‘%’)putchar(c);} while (c != SERIAL_TIMEOUT && c != ‘$’ && c != ‘%’);
这样就没问题了!
,没有行囊,没有目的,我孤独的走在路上,