接上一篇帖子http://www.geek-workshop.com/thread-27377-1-1.html
收到的数据如下,
可以看到数据几乎收了一半,正常数据是AA 01 01 0D 2D 00 00 03 FB 00 41 14 81 81 B2 2F B5 55 83 ,其中AA、55分别是起始位、停止位,中间部分数据位41、14收到的正确,但有些数据前不知道为什么加上FFFFFF,如下
FFFFFF81
FFFFFF81
FFFFFFB2
不是很理解,还有开始几位只收到每个字节的低位,如下,
1
D
2D
0
0
3
是不是串口把每个字节高位0给过滤掉了,我的程序没有过滤啊
程序还是之前的程序,大家指点一下,- File myFile;
- char inByte; // incoming serial byte
- void setup()
- {
- Serial.begin(1200,SERIAL_8E2);
- while (!Serial) {
- ;
- }
- pinMode(10, OUTPUT);
- if (!SD.begin(4)) {
- return;
- }
- }
- void loop()
- {
- myFile = SD.open("test01.txt", FILE_WRITE);
- if (myFile)
- {
-
- if (Serial.available() > 0)
- {
- inByte = Serial.read();
- Serial.println(inByte,HEX);
- myFile.println(inByte,HEX);
- }
-
- delay(500) ;
- }
- }
复制代码 |