Serial strange behaviour
Re: Serial strange behaviour
Great! SoftwareSerial library work like a charm, adopted! Do you plane to support find and readBytesUntil functions ?
Re: Serial strange behaviour
Hum, output seems dirty. I introduce a buffer (buf) to avoid Serial overhead.
Z-Uno output
Code: Select all
#include "SoftwareSerial.h"
SoftwareSerial swserial(11, 12); // duplex mode on pins 11 and 12
char buf[512];
int i=0;
void setup() {
swserial.begin(1200);
Serial.begin(9600);
}
void loop() {
while(swserial.available()){
buf[i]= swserial.read() & 0x7F;
i++;
if(i==511){
Serial.println(buf);
i=0;
}
}
delay(1000);
}
Raspberry output (clean)ADCO 02T 00` Y
IAX@`40 9
HCHC 009TAT 000000 B
.
IINST 002 Y
ISOUSC 30 9
/
MTDETAT 000TEC HP..
IIF HC.. <
ISO
HHPHC D .
O05708 1
PTEC H>
OPTARIF HCP 00390 -
HHPHH
ADCO 524563565245 /
OPTARIF HC.. <
ISOUSC 20 8
HCHC 001065963 _
HCHP 001521211 '
PTEC HC.. S
IINST 001 I
IMAX 008 2
PAPP 01250 +
HHPHC E 0
MOTDETAT 000000 B
Re: Serial strange behaviour
May be this is because you read 7n1 with 8n1?
Re: Serial strange behaviour
You can't read 7n1 with this, cause it has different timing. Stop bit will be "too early". I can give an idea how to modify the code of library for your purposes. How many bytes do you have in one portion of data? At this moment library uses 32 bytes for cyclic buffer.
Re: Serial strange behaviour
Here is a modified version of Library. Place it to libraries folder an use like this:
Code: Select all
#include <SoftwareSerial7N1.h>
SoftwareSerial7N1 swserial(11, 12);
// ...
- Attachments
-
- ZUNO_SofwareSerial7N1.zip
- (2.89 KiB) Downloaded 254 times
Re: Serial strange behaviour
Interesting, it gives an idea on how to modify SoftwareSerial library to support more coding method.p0lyg0n1 wrote: ↑24 Jun 2018 17:43Here is a modified version of Library. Place it to libraries folder an use like this:Code: Select all
#include <SoftwareSerial7N1.h> SoftwareSerial7N1 swserial(11, 12); // ...
I think I'm wrong with 7n1. According following documentation extract, I'm based on 7e1 (7 data bits, 1 parity bit and 1 stop bit).
As far as I understand, the SoftwareSerial library works twice speed as baud speed. It detects 0L and counts 8 bits. How is done synchronization ? How to be sure that 0L is a start bit and not a data bit ?
Re: Serial strange behaviour
Start bit is always 0, stop bit is always 1. So, the first 0 is the start of transition. It's a main rule of UART protocol. So we have to work twice faster to follow the theorem of discretization. Looks like you could use the simple 8N1 UART. I don't understand why it's not work for you. Could you connect a logic analyzer to your device? Something like saleae or it's clone. At least you could use Arduino as logic analyzer for your case. The baudrate is not fast. See this https://hackaday.io/project/1633-arduin ... c-analyzer