LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-13-2011, 12:44 AM   #1
alireza976
LQ Newbie
 
Registered: May 2011
Posts: 13

Rep: Reputation: Disabled
problem with mbusd source code


Hello

when modbus program (free MODBUS/TCP to MODBUS/RTU gateway server (mbusd)) on ttyS0 is run, inserted parameter not initialize.
Quote:
$ mbusd -d -v 2 -p /dev/ttyS0 -P 502 -s 19200 -R 1 -W 25 -C 128
1307941684:339882 mbusd-0.1.2 started...
Quote:
$ stty -F /dev/ttyS0 -a
speed 0 baud; cs5 -cread -clocal ,...
But when i run this command in command line : $ stty -F /dev/ttyS0 speed 19200 cs8 cread , modbus program works without any error.

this section of mbusd source code is for initializing :
Quote:
/*
* Setting up tty device MOD attributes
*/
int
tty_set_attr(ttydata_t *mod)
{
int flag;

if (tcgetattr(mod->fd, &mod->savedtios))
return RC_ERR;
memcpy(&mod->tios, &mod->savedtios, sizeof(mod->tios));
mod->tios.c_cflag &= ~(CSTOPB | PARENB | PARODD | CRTSCTS);
mod->tios.c_cflag |= CS8 | CREAD | CLOCAL;
mod->tios.c_iflag = FALSE;
mod->tios.c_oflag = FALSE;
mod->tios.c_lflag = FALSE;
mod->tios.c_cc[VTIME] = 0;
mod->tios.c_cc[VMIN] = 1;
#ifdef HAVE_CFSETSPEED
cfsetspeed(&mod->tios, tty_transpeed(mod->speed));
#else
cfsetispeed(&mod->tios, tty_transpeed(mod->speed));
cfsetospeed(&mod->tios, tty_transpeed(mod->speed));
#endif
if (tcsetattr(mod->fd, TCSANOW, &mod->tios))
return RC_ERR;
#if defined(TIOCSETA)
ioctl(mod->fd, TIOCSETA, &mod->tios);
#else
/* if TIOCSETA is not defined, try to fallback to TCSETA */
ioctl(mod->fd, TCSETA, &mod->tios);
#endif
tcflush(mod->fd, TCIOFLUSH);
#ifdef TRXCTL
tty_clr_rts(mod->fd);
#endif
flag = fcntl(mod->fd, F_GETFL, 0);
if (flag < 0)
return RC_ERR;
return fcntl(mod->fd, F_SETFL, flag | O_NONBLOCK);
}
If the source code has any problem?
anybody can help me to solve this problem.

Thanks

Last edited by alireza976; 06-13-2011 at 01:07 PM.
 
Old 06-13-2011, 01:50 AM   #2
alireza976
LQ Newbie
 
Registered: May 2011
Posts: 13

Original Poster
Rep: Reputation: Disabled
when working with usb to serial adapter and cable, mbusd program works without any problem. (/dev/ttyUSB0)
but when working with serial port (/dev/ttyS0) does not work.

In builder site (mbus.sourceforge.net) posted :
Please note that currently mbusd can't operate with RS-232/RS-485 converters with direction switching by RTS pin. Use converters with automatic data direction control (i.e. Moxa Transio series).

why when i use "$ stty -F /dev/ttyS0 speed 19200 cs8 cread" on ttyS0 my mbusd starts working?

Last edited by alireza976; 06-13-2011 at 01:59 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
can not kill mbusd process and can not run it again golden_boy615 Linux - General 3 11-02-2010 02:58 AM
Squid source code installation problem gulnawaz Linux - Server 3 12-03-2009 10:30 AM
iptables source code problem Ashkan_s Linux - Software 2 08-07-2008 10:11 AM
problem in source code dileepkk Linux - General 5 09-29-2004 07:36 PM
Problem in compiling source code JIV Linux - Software 1 02-14-2004 03:11 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration