I want to restrict a serial port baud rate to 2400 instead of the default value.

General support questions including new installations
Post Reply
abin4321
Posts: 2
Joined: 2016/11/14 06:55:48

I want to restrict a serial port baud rate to 2400 instead of the default value.

Post by abin4321 » 2016/11/14 06:59:58

I have a device which works on 2400 bps baud rate speed, i am using a 3rd party application which sets the baud rate to 19200 bps. so sync is not happening. I can change the value to 2400 using command/script. (That's working fine).
I want a solution to restrict the baud rate to 2400, even application can't change it.
Kindly suggest.

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: I want to restrict a serial port baud rate to 2400 instead of the default value.

Post by aks » 2016/11/14 17:55:00

Can't you just set it (say in rc.local) via mgetty -s 2400 /dev/ttyS0 (or whatever device it is), or something like stty -F /dev/ttyS0 2400 cread cs8 -cstopb -parenb (more options used here). I don't think you can get udev to do it, when it "enables" the hardware - well you might with some custom udev rules, but I'll leave that to you to work out.

As far as some process that can change it, I doubt you could, but I guess you could change the permissions of the device so only a certain user (or root) can read/write to it (a simple udev rule would work for that). Unless you applications run as root of course.

abin4321
Posts: 2
Joined: 2016/11/14 06:55:48

Re: I want to restrict a serial port baud rate to 2400 instead of the default value.

Post by abin4321 » 2016/11/15 04:39:48

Yes, the application is running as root.
I want to know in which file the baud rate settings are defined. Can't we change that?
Or is there any macro defined for baud rate selection? What if we just change the baud rate value there.

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: I want to restrict a serial port baud rate to 2400 instead of the default value.

Post by aks » 2016/11/15 17:10:55

I think it's a hardware state. As the app runs as root, it can overwrite whatever values you set when it launches and opens the serial port.
You could use the stuff I posted earlier to set the various states, but it could always be overwritten anyway.

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: I want to restrict a serial port baud rate to 2400 instead of the default value.

Post by TrevorH » 2016/11/15 17:51:34

If you run lsmod and look at the modules that are loaded you should be able to work out which are used for your serial port. Then run modinfo against each of those in turn and see if they take any parameters that might be used to artificially cap the baud rate.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

Post Reply