• Welcome to Forum.Deepsoftware.Com. Please login or sign up.
 

How to implement a 9 bit

Started by Foster, December 12, 2011, 01:35:59 pm

Previous topic - Next topic

Foster

I am writing a program in C# (program is currently using SerialPort class in .NET 4.0)
I must use 9 data bits
Only 1 or 2 of sent bytes must have the 9 bit logic 1,  or Mark Parity.
Normal receive data the 9 bit is logic 0 or space parity

Eaample data
0x01 0x01 0x51 0x08 (first byte sent with mark parity (0x01) rest sent with space parity (0x01 0x51 0x08)

I get framing errors using the SerialPort class

using NrComm library what is the best way to emulate it
I try changing parity on the fly and I get exception errors. 
Apply setting is failed! Possible is wrong combination of serial port settings.

example of how I changing parity
lines I use to change parity
  myserialPort.Parity = Parity.Mark;
  myserialPort.Parity = Parity.Space;

in my Form code
I know the first line is correct because I can set the initial properties (Baud Rate, data bits, stop bits, initial Parity)
it wot let me change them (I gather no changes allowed while port open)
myserialPort = new NrComm(); 
myserialPort.UseMainThread = true;

it is not allowing me to change parity when needed, I can not just set mark parity (the device I am communicating wont look at rest of the data (it will think every byte is an address byte)

The reason I am trying your comm library is to overcome the framing errors and a couple of other issues I am having (repeated receive data - I see the same byte many times (2-10 times)

Roman Novgorodov

Hello

9bit size is not available for serial port system driver of windows.

You can play with stop bits together with parity, but I do not think that it is possible.

Roman Novgorodov
DeepSoftware LLC
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

Foster

What is the trick to switching parity between mark and space parity while port is open?

Roman Novgorodov

Hello

There are no special tricks just change Parity and StopBits properties or call ConfigDialog() while port open.

Roman Novgorodov
DeepSoftware LLC
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

mawg

February 10, 2012, 12:16:13 am #4 Last Edit: February 10, 2012, 04:26:43 am by Roman Novgorodov
Yes, it *can* be done, but you might have to pay. I got this reply from someone selling a solution, and am still looking for a free solution


thank you for your interest in our products.

Yes, the Serial Module (as part of the »RealTime Suite«) can handle 9 data bits and does support Delphi as well. The current implementation of the Serial Module (UART API) needs a 16550-compatible UART hardware and supports all built-in COM ports as well as a number of external PCI/PCIe-cards. Supported hardware is currently:

PCI-Bus
   MOXA: IndustIo CP-132 (2xSER, RS-422/485)
   MOXA: IndustIo CP-114 (4xSER, RS-422/485)
   MOXA: SmartIo C104H/PCI (4xSER)
   MOXA: SmartIo C168H/PCI (8xSER)
   ADDI-DATA: APCI-73xx (1xSER)
   ADDI-DATA: APCI-74xx (2xSER)
   ADDI-DATA: APCI-75xx (4xSER)
   Brainboxes: PCI 4 Port Serial Card (z.B. CC-268) (4xSER)
   TCL: DataBooster (4xSER/8xSER) (via IoPort access)
   SUNIX: 4088A/4089A (2xSER,2xPAR)
   LINDY: 70585 (2xSER)
   LINDY: 70616 (2xSER,2xPAR)
   EXSYS: EX-41051 (1xSER)
   EXSYS: EX-41052 (2xSER)
   Wiesemann & Theis: 13812 (2*SER, RS-232, 1kV isolated)

CardBus 32-Bit
   QUATECH: Serial I/O PC Card SSP-100 (1xSER)
   SOCKET: Serial I/O PC Card (1xSER)

<!!!>

If you wish to support other hardware, this is in most cases possible with low effort. Please give us some information about the hardware and we can see if it's possible.

Roman Novgorodov

Hello

This solution (Kithara Serial Module) uses kernel drivers for direct access to serial port controller.
It is not suitable for simple serial port I/O operations in 99% tasks.

Link is removed as advertisment :-)

Roman Novgorodov
DeepSoftware LLC
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

mawg

Sorry about the "advertisement". I was just trying to help.

Nvm, at least we have progressed from "9bit size is not available for serial port system driver of windows" to "It is not suitable for simple serial port I/O operations in 99% tasks".

If the OP, like me, is one of the 1% then at least he knows now that there is hope.

Bottom line: it _can_ be done. You can do it yourself with a lot of effort and maybe a lot of reading; or buy buying a commercial product. I leave that decision p the OP.