How to detect the address bit

I am communicating with a protocol thats uses 1 start bit, 8 data bit, 1 address/data bit and 1 stop bit (No parity). The address/data bit is used to identify the start of a frame In the first byte, in each frame the address/data is 1. The rest of the bytes in the frame is 0.

In the protocol specification, it says: “A great number of single chip micro processors from various manufactures are able to detect this address/data bit”

How/can I detect this address/data bit in Linux?

Linux dosnt support 9 data bit as standard. I have tryied pretending that the address/data bit is a parity bit instead. To make this work i would have to use Mark or Space parity. Im having a really hard time making space and mark parity work in my program. I know that Linux have implementet the command CMSPAR (termios.h), but it dosnt work very well with me.
It could really help if someone posted a code example, using space/mark parity. Also a list of what files and what there should be in them so I can use this parity.

I have to read AND write with the protocol.

Any help at all, is very welcome

FAQ: RedHat 9, C++, KDevelop, kernel: 2.4.20-31.9, Digi Neo serial card

Sample sent to your e-mail address.

Hey userid0

Thank you for the code sample. Very nice of you.
But it didnt work for me. Maybe its the way I open the serial port:

static int com1 = 0;
struct termios com1_termios;

int ComSetting::openAdrPort(char com1Number)
char com1navn[64];
printf("Port: %c
", com1Number);
sprintf(com1navn, “/dev/dg/dgnc/ttyn1%c”, com1Number);
printf("Portnavn: %s
", com1navn);

// make sure port is closed
// make sure RTS is low

com1 = open(com1navn, O_RDWR | O_NOCTTY |   O_NDELAY);//| O_NONBLOCK |

if (com1 < 0)
    printf("Open error com %d %s

", errno, strerror(errno));
fcntl(com1, F_SETFL, 0);
tcgetattr(com1, &com1_termios);

    bzero(&com1_termios, sizeof(com1_termios));
    com1_termios.c_cflag = B75 | CS8 | CRTSCTS | CLOCAL | CREAD;
    com1_termios.c_iflag = INPCK | PARMRK;
    com1_termios.c_oflag = 0;

    // set input mode (non-canonical, no echo,...)
    com1_termios.c_lflag = 0;

    com1_termios.c_cc[VTIME] = 1;   
    com1_termios.c_cc[VMIN] = 0;   

    tcflush(com1, TCIFLUSH);

return com1;



Is it possible to send me your code samle for using the 9. bit as command(mark)/data(space) bit flag instead for parity checking ? Thanks in advance.

my e-mail:

dear userid0/newbie/AndersH:
i come across the same problem. Can you send me a sample code of mark and space parity ?
Any help is very welcome!

my e-mail:

Due to a large demand, here is the code sample for mark and space parity in Linux with the dgnc driver (NEO and ClassicBoard adapters):

int SetParity(int parity)


int result=0;

if (fd < 0){

return -1;


// Get original settings

result=tcgetattr (fd, &options);

switch (parity) {

case 0: options.c_cflag &= ~PARENB; break;

case 1: options.c_cflag |= PARENB;

options.c_cflag &= ~PARODD; break;

case 2: options.c_cflag |= PARENB;

options.c_cflag |= PARODD; break;

case 3: //options.c_cflag |= PARENB;

options.c_cflag |= CMSPAR;

options.c_cflag |= PARODD; break;

case 4: //options.c_cflag |= PARENB;

options.c_cflag |= CMSPAR;

options.c_cflag &= ~PARODD; break;




if (-1 == tcsetattr (fd, TCSADRAIN, &(options))) {

return -1;


return 1;