Issue with SoftwareSerialwithhalfduplex working in 8n2

Good evening
I am quite newbie in Arduino with limited background in electronics
I try to use SoftwareSerialwithhalfduplex library and it is working well between 2 Arduinos
I implemented a simple sketch to send smbus command to a Lithium battery but get no answer.
I thus checked with oscilloscope the bit sequence and it appears to be 8n2 (2 stop bits)
I thought this library was sending data under 8n1 “format “?
Could someone confirm me if there is a way to adapt the library to send with 8n1 protocol or maybe there is a more adapted library?
Thanks in advance

A delay after sending each byte will appear as extra stop bits! Is your program doing that?

Paul

You can do:

Serial.begin(<speed>, SERIAL_8N2);

Thanks a lot for these information.
I will test and keep you informed

@Paul,
Hi Paul, I have no delay in the program.
See below.

[code]
#include <SoftwareSerialWithHalfDuplex.h>

#define comPin 10

// add arguments of false (for inverse_logic?), false (for full-duplex?) for half duplex.
// you can then use the same pin for both transmit and receive.
SoftwareSerialWithHalfDuplex debugPort(comPin,comPin,false,false);

String readString;


void setup(){
  debugPort.begin(38400);         // to connect with other devices
  Serial.begin(9600);            // to see who's connected
}

void loop(){

delay(3000);
debugPort.write(0x10);
debugPort.write(0x01);
debugPort.write(0x04);
debugPort.write(0x07);
debugPort.write(0x0b);
debugPort.write((byte)0x00);
debugPort.write(0x07);
debugPort.write(0x01);
debugPort.write(0x6b);
debugPort.write(0x10);
debugPort.write(0x04);
//debugPort.end(); // utilisé pour vider le buffer car sans cela, la boucle ci dessous lisait des 0000, autant que de 0x envoyés en debugPort.write!?
//debugPort.begin(38400);
debugPort.flush();

for (int i=0; i<40; i++) {
      while(!debugPort.available()); // wait for a character
    int incomingByte = debugPort.read();
    Serial.write(incomingByte);
    }

    delay(1000);
}

[/code]

PErhaps it is in here: SoftwareSerialWithHalfDuplex.h>, when the check for a character being returned on the receive line.

Paul

Dear Paul,

This is out of my competence to investigate the SoftwareSerialWithHalfDuplex.h.

I also noticed a strange behaviour. Transmission is as follow for every byte:
1 bit start /8 data bits and then 2 stop bits.
The duration of these 2 stop bits is not consistent.
Normally every bit is about 26us ( corresponding to 38400 baud rate). This is true for every bit (Start/Data) but most of the 2 Stop bits have a total duration of 46,8us (instead of 52us).

Any idea?

@POWER_BROKER

Hi, it seems there is no such argument available when using SoftwareSerialWithHalfDuplex.h

Technically, stop bits can be as long as needed, could be minutes long. The actual minimum length is what is important.

Paul