USB support in Linux

Linux specific questions.
caseih
Posts: 1518
Joined: Feb 26, 2007 5:32

Re: USB support in Linux

Postby caseih » Aug 07, 2015 22:33

Dinosaur wrote:Hi All

Problem is now identified as Baud rate.
When opening the port with FB program line:

Code: Select all

        Open Com "/dev/ttyUSB0:38400,n,8,1,cs0,ds0,cd0,rs" For Binary As #CP
it opens the port at the default Baud rate set by the Linux system.
On my system, it happens to be 115200.


In Dos, you could use a Mode statement to set the baud rate.
Is there such a statement in Linux ?

Well the stty command can set the baud rate as well as determine what it is. There're also some API calls you can make using the termios.h file, which is how you do it from C (http://stackoverflow.com/questions/6947 ... -port-in-c).

Looks to me like a bug in the runtime library. I reduced the test to just:

Code: Select all

Open Com "/dev/ttyUSB0:38400" For Binary As #1

and confirm it does not set the baud rate. Running minicom or stty does, though.

Probably we should have the list moderators change the subject of this thread to "Serial support in Linux" since it's more about accessing serial ports, whether physical or USB. I started to look through the runtime library source files, but I haven't had time to figure out where the actual serial port code is.
caseih
Posts: 1518
Joined: Feb 26, 2007 5:32

Re: USB support in Linux

Postby caseih » Aug 07, 2015 22:48

I looked in the runtime code and it sure looks like it's trying to set the baud rate. Also, when the serial port is closed, FB will restore the port settings to what they were before you opened the port. So just because stty reports 115200 doesn't mean that's what FB is setting it to. So maybe the stty thing was a false lead. At this point I'm confused! I guess I could comment out the line in the runtime that restores the previous serial port settings on close so we could get a better look at what FB is doing to the port. Unfortunately I can't run stty on the serial port while FB has it open.

Also FB attempts to make COM# notation work on Linux, but it's only for built-in ports. COMx becomes ttySx-1.
Dinosaur
Posts: 1357
Joined: Jul 24, 2005 1:13
Location: Hervey Bay
Contact:

Re: USB support in Linux

Postby Dinosaur » Aug 07, 2015 23:55

Hi All

At this point in time this issue is not holding me up.

caseih I am reliant on the developers to solve this problem.
That is, if this is a problem for Linux across the board.
I am running Linux Mint, what flavour are you running that is also showing the problem.

Can someone else confirm the same problem with other Linux distro's

Regards
speedfixer
Posts: 404
Joined: Nov 28, 2012 1:27
Location: California

Re: USB support in Linux

Postby speedfixer » Aug 09, 2015 17:55

To ensure that Linux ports are setup as requested, typical solution is to tell Linux OS what you want first, as:


Code: Select all

    shell "stty -F /dev/ttyUSB0 speed 9600 -clocal -hupcl"
    sleep 1000
    open com "/dev/ttyUSB0:9600,n,8,1,cs0,cd0,ds0,rs" as #filnum


You have a little more control over what you are doing, not trusting FB and Linux matches.

David
Dinosaur
Posts: 1357
Joined: Jul 24, 2005 1:13
Location: Hervey Bay
Contact:

Re: USB support in Linux

Postby Dinosaur » Aug 09, 2015 18:10

Hi All

Thanks for that David.

I looked at the command, but only saw ispeed & ospeed, and when I tried them they failed.
That whole issue is shady in my opinion.
When I use your suggestion in the Terminal it replied with 38400
Then using stty on it's own it replied with 115200
Then using your statement again, it replied with 9600 ???

Regards
speedfixer
Posts: 404
Joined: Nov 28, 2012 1:27
Location: California

Re: USB support in Linux

Postby speedfixer » Aug 09, 2015 19:08

yes.

It seems Linux always replies with the baud as set *before* the operation.

But the change was made..

David
speedfixer
Posts: 404
Joined: Nov 28, 2012 1:27
Location: California

Re: USB support in Linux

Postby speedfixer » Aug 09, 2015 19:11

You also have to remember that almost every terminal program has some init process that will set the desired port to some expected inititial settings. They usually don't 'float' with whatever is already present.

Each terminal run will reset the port in the OS.
rsneha
Posts: 1
Joined: Jul 09, 2020 13:26

Re: USB support in Linux

Postby rsneha » Jul 09, 2020 13:28

caseih wrote:You're very welcome.

Yes you are reading the vendor id and product id correctly. Does the Adam symlink show up in /dev when you plug it in? If so, then you got it.

So to answer your questions, the MODE refers to permissions on accessing the device node entry in /dev. It's in standard unix octal numbering, but 0666 means read and write for the owner (root), the group (wheel), and everyone else. This numbering is the same numbering used by the chmod command.

The wheel group is an old unix standard group that gives users a few administrative privileges. Some things like shutdown and reboot from the command line require you to be in the wheel group. Depending on your distro, you may be in the wheel group already. Note that with 0666 as the mode on the file, it doesn't matter what group you're in, so the GROUP option probably could be left out entirely.

For more information on unix permissions, I'm sure there are lots of web pages. Here's a handy calculator for those unfamiliar with how to come up with the number: http://permissions-calculator.org/

When you change a udev rule, you don't have to reboot. You can run this command:
sudo udevadm control --reload-rules

Also check this site : https://www.easyunitconverter.com/chmod-calculator

Return to “Linux”

Who is online

Users browsing this forum: No registered users and 0 guests