P1 Serial1 7N1 operations?

I’m attempting to sniff serial data from a 9600,7,N,1 dot matrix serial printer link, and I’m discovering the Serial1 UART fails to recognize data in this mode despite the following setup:

Alternatively, configuration may be constructed manually by ORing ( `|` ) the following configuration constants:

Data bits:

* SERIAL_DATA_BITS_7 - 7 data bits
* SERIAL_DATA_BITS_8 - 8 data bits
* SERIAL_DATA_BITS_9 - 9 data bits

Stop bits:

* SERIAL_STOP_BITS_1 - 1 stop bit
* SERIAL_STOP_BITS_2 - 2 stop bits
* SERIAL_STOP_BITS_0_5 - 0.5 stop bits
* SERIAL_STOP_BITS_1_5 - 1.5 stop bits

Parity:

* SERIAL_PARITY_NO - no parity
* SERIAL_PARITY_EVEN - even parity
* SERIAL_PARITY_ODD - odd parity

What are my options (if any) with using the UART?
I have yet to check, however, if the SoftSerial class supports this?

@jimini, which printer is it? Also, which Particle device are you using? If the printer uses RS232 level signals vs TTL, you cannot connect the line directly to the RX pin of the Particle device (see here for explanation). Doing so may damage your Particle device.

You will need an RS323-to-TTL level converter such as ones that use a MAX232 chip. You could use something like this, powered by 3.3v from your Particle device:

Once you have that in place, you can test different congurations. You could also get a converter that works with a PC so you can test there first. The converter is like these:

P1 with all the EIA 232/3V3 level shifting…
It is a serial dot matrix ticket printer that we’ve validated DIP settings.
It’s a serial setup question, not an interface question

@jimini, a version of SoftwareSerial by @ScruffR is available but I don’t think it would help. However, if you haven’t already, you could try:

Serial1.begin(9600, SERIAL_DATA_BITS_7 | SERIAL_STOP_BITS_1 | SERIAL_PARITY_NO);

Does this produce anything, assuming you sent any received chars to the Serial output. You could also try 8N1 to see if you get anything.

Serial1.begin(9600, SERIAL_DATA_BITS_8 | SERIAL_STOP_BITS_1 | SERIAL_PARITY_NO);

I assume you verified the printer settings by sending something to it via a PC? If this doesn’t work, you could try a different baudrate, either 4800 or 19,200 to see if that help.

BTW, if you have an oscilloscope, you should verify the signal is clean on the Serial1 RX line.

Thanks, however,

I've config'd as you've enumerated here, and I've sim'd this on my bench using the XCTU frame generator via 7,N,1 format to no avail... it's not an interface issue at all, way past that.

Again, just needing someone to validate the UART does/does-not operate here.

Understood. It would have been good to include these details to begin with. Which deviceOS are you using?

AFAICT not all combinations are supported and 7 bit without parity is not listed here either
Device OS API - Photon | Reference Documentation | Particle

It’s a while since, so I’m not sure I implemented 7N1 in ParticleSoftSerial but it shouldn’t bee too hard to add if it’s not already there :wink:

@peekay123
thread topic and first post recaps what was in play (I least I intended it as such)
running v.0.6.3

@ScruffR
exactly where I’m heading

thanks guys

I just checked the code (but not tested) and 7N1 should be supported in ParticleSoftSerial.

The STM32F2xx does not support 7-bit mode without parity. So 7N1 and 7N2 are not possible on the hardware USARTs on Gen 2 devices.

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.