The connection to the train should be set to 2400 baud with 1 start bit,
2 stop bits, 8 data bits and no parity check.
The
code fragement below will help you enable these settings.
/*
* XON8250_PORT_INIT (Cmd) configures the 8250
* cmd is a string of the form baud parity stop data ... i.e.
* 300 n 1 8
*
* baud - 300, 600, 1200, 2400, 4800, 9600, 19200
* parity - n -> no parity check 0
* o -> odd parity 1
* e -> even parity 2
* stop - 1 -> 1 stop bit
* 2 -> 2 stop bits
* data - 5, 6, 7, 8 data bits
*
* Note: This assumes polled IO, not interrupt driven.
*
*/
void nsc8250_port_init(
u_short port, /* base address in IO space for serial port */
unsigned int baud,
unsigned int data,
unsigned int parity,
unsigned int stop)
{
unsigned mode_word;
stop = ((stop-1) & 1);
stop <<= 2;
baud /= 10;
baud = 11520 / baud;
parity <<= 3;
parity &= 0x018;
data -= 5;
data &= 3;
mode_word = data | stop | parity;
outb(port + LCR, inb(port + LCR) | LCR_DLAB);
outb(port, baud % 256);
outb(port + 1, baud / 256);
outb(port + LCR, mode_word & 0x7F);
/* turn on DTR and all other outputs (harmless) */
outb(port + MCR, 0x0F);
/* turn off all interrupt sources */
outb(port + IER, 0);
/* turn on FIFO, but tell it to make interrupts (if they
* were enabled when the FIFO has one item.
*/
outb(port + FCR, 0x0f);
/* Read pending input and status bits (ignore them)... */
inb(port + LSR);
inb(port + MSR);
inb(port);
}