Page 3 of 3

Re: Serial strange behaviour

Posted: 23 Jun 2018 16:00
by vebryn
Great! SoftwareSerial library work like a charm, adopted! Do you plane to support find and readBytesUntil functions ?

Re: Serial strange behaviour

Posted: 23 Jun 2018 18:27
by vebryn
Hum, output seems dirty. I introduce a buffer (buf) to avoid Serial overhead.

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);
}
Z-Uno output
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
Raspberry output (clean)
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

Posted: 24 Jun 2018 08:59
by PoltoS
May be this is because you read 7n1 with 8n1?

Re: Serial strange behaviour

Posted: 24 Jun 2018 17:03
by p0lyg0n1
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

Posted: 24 Jun 2018 17:43
by p0lyg0n1
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);
// ...

Re: Serial strange behaviour

Posted: 27 Jun 2018 22:40
by vebryn
p0lyg0n1 wrote:
24 Jun 2018 17:43
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);
// ...
Interesting, it gives an idea on how to modify SoftwareSerial library to support more coding method.

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).

Image

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

Posted: 28 Jun 2018 23:46
by p0lyg0n1
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