Linux port problem with Raspberry Pi

Linux specific questions.
BasicCoder2
Posts: 3391
Joined: Jan 01, 2009 7:03

Linux port problem with Raspberry Pi

Postby BasicCoder2 » Aug 02, 2019 4:52

After successfully communicating between a FreeBasic Window's program and the Arduino I decided to try the Raspberry Pi with its Linux system.

The Arduino IDE downloaded and worked fine on the RPi so it was able to use the Rpi USB to Arduino connection without any problem.

Although the FreeBasic Linux program compiled successfully it failed to execute with an error opening the com port.
error opening com3

The port address used by the Arduino IDE was shown as,
Port:"/dev/ttyACMO(Arduino/Genuine Mega or Mega 2560)"

So I changed:
Dim As String com_cmd = "COM3:9600,n,8,1,cs0,ds0,cd0,rs"
to,
Dim As String com_cmd = "/dev/ttyACMO(Arduino/Genuine Mega or Mega 2560):9600,n,8,1,cs0,ds0,cd0,rs"
without success so I assume Linux does the ports differently to Windows?

This was the FreeBasic code in question given by MrSwiss that works on Windows and I was trying to get to work with Linux (Raspian).

Code: Select all

screenres 640,480,32

Dim As Long     fn = FreeFile
Dim As String   com_cmd = "COM3:9600,n,8,1,cs0,ds0,cd0,rs"

If Open Com(com_cmd As #fn) <> 0 Then
    Print "Error opening COM3"
    Sleep 2000, 1
    Cls
    End 1
End If
   
dim as string outData, inData


do
    outData = inkey
    If outData <> "" Then
        print #fn, outData             ' SEND DATA

        While LOC(fn) = 0               ' wait until ARDU responds
            Sleep 20                    ' (forever, if no answer!)
        Wend
       
        inData = ""
        while Loc(fn) > 0
            inData += Input(1,#fn)      'acknowledge data received
        Wend
       
        'print inData

    End If
   
    Sleep 20
loop until outData = "q"  'multikey(&H01)

Close #fn
D.J.Peters
Posts: 7780
Joined: May 28, 2005 3:28

Re: Linux port problem with Raspberry Pi

Postby D.J.Peters » Aug 02, 2019 7:59

type in a console

ls -a /dev/tty*

and see does the device name you use really exist
and not a virtual link is created by the ARDUINO IDE !.

May it's "/dev/ttyACMO"

(shorter and without any Spaces in the name !)

Be sure the ARDUINO IDE is closed for the test while you open the port may be it's busy if the IDE use it.

Years ago I wrote a FreeBASIC program to communicate with an older USB oscilloscope (lo level libUSB without an driver for this windows only device)
all my tests failed at the beginning but I found out if I run my program as root like:

sudo ./myprogram
passwd: *****

It worked very well !

Joshy
BasicCoder2
Posts: 3391
Joined: Jan 01, 2009 7:03

Re: Linux port problem with Raspberry Pi

Postby BasicCoder2 » Aug 02, 2019 10:01

Thanks Joshy it was /dev/ttyACM0
It worked with the ARDUINO IDE open although I didn't try it with the Serial Monitor on.
One thing I noticed was that when the program was run with Build > Execute the console window was selected and I had to click the program window to select it instead. I am using Geany. On Windows I was using FBIDE.

Return to “Linux”

Who is online

Users browsing this forum: No registered users and 5 guests