Author Topic: How to implement a 9 bit  (Read 2240 times)

Foster

  • Newbie
  • *
  • Posts: 2
    • View Profile
How to implement a 9 bit
« on: December 12, 2011, 03:35:59 pm »
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

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: How to implement a 9 bit
« Reply #1 on: December 20, 2011, 03:41:43 pm »
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

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: How to implement a 9 bit
« Reply #2 on: December 23, 2011, 06:42:52 am »
What is the trick to switching parity between mark and space parity while port is open?

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: How to implement a 9 bit
« Reply #3 on: December 23, 2011, 06:48:25 am »
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

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: How to implement a 9 bit
« Reply #4 on: February 10, 2012, 02:16:13 am »
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.
« Last Edit: February 10, 2012, 06:26:43 am by Roman Novgorodov »

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: How to implement a 9 bit
« Reply #5 on: February 10, 2012, 06:25:06 am »
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

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: How to implement a 9 bit
« Reply #6 on: February 14, 2012, 03:10:34 am »
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.