Serial Port on Linux/Pandora

Previous topic - Next topic

Julian

I finally got my pandora and now I am trying to get serial port communication working. The device is connected via rfcomm0. I am using this library: http://www.glbasic.com/forum/index.php?topic=1690.0
At first it didn't compile:
Quote_______________________________________
*** Configuration: PANDORA ***
precompiling:
GPC - GLBasic Precompiler V.9.829 SN:XXXXXXX - 3D, NET
Wordcount:40 commands
compile+link:
C:\Users\Julian\AppData\Local\Temp\glbasic\gpc_temp1.cpp: In function 'int OpenAdrPort(int, int)':
C:\Users\Julian\AppData\Local\Temp\glbasic\gpc_temp1.cpp:484: error: too few arguments to function 'void CloseAdrPort(int)'
C:\Users\Julian\AppData\Local\Temp\glbasic\gpc_temp1.cpp:526: error: at this point in file
C:\Users\Julian\AppData\Local\Temp\glbasic\gpc_temp1.cpp:532: error: 'fd' was not declared in this scope
*** FATAL ERROR - Bitte die Compiler-Ausgabe ins Forum kopieren
Then I changed a view things:
QuoteError fixing:
Line 278:   CloseAdrPort();    =>   CloseAdrPort(iSlot);
Line 281:   if (fd < 0)      =>   if (g_hSerialFile[iSlot] < 0)
tty to rfcomm:
Line 275:   DGStr sPortName = "/dev/ttyS"+iRS232Port;   =>   DGStr sPortName = "/dev/rfcomm"+iRS232Port;
My testcode looks like this:
Code (glbasic) Select
PRINT "Opening Serial Port....",0,0
SHOWSCREEN

IF comopen() = FALSE
PRINT "Failed",0,0
SHOWSCREEN
KEYWAIT
RETURN
ENDIF

WHILE TRUE
PRINT readserialline$(),0,0
IF KEY(1) = 1; RETURN; ENDIF
SHOWSCREEN
WEND


FUNCTION readserialline$:
LOCAL buffer$ = ""
LOCAL line$ = ""
WHILE ASC(buffer$) <> 10
buffer$ = COM_Read$(0,1)
IF ASC(buffer$) <> 10 OR ASC(buffer$) <> 12 THEN line$ = line$ + buffer$
WEND
RETURN line$
ENDFUNCTION

FUNCTION comopen:
INIOPEN "settings.ini"
LOCAL port%  = INTEGER(INIGET$("GPS","COMPORT",1))
LOCAL baud   = INTEGER(INIGET$("GPS","BAUDRATE",9600))
LOCAL parity = INTEGER(INIGET$("GPS","PARITY",0)) // 0=none, 1=odd, 2=even, 3=mark, 4=space
LOCAL datab  = INTEGER(INIGET$("GPS","DATABITS",8)) // data bits
LOCAL stop   = INTEGER(INIGET$("GPS","STOPBITS",0)) // stop bits: 0=1 (ONE) stop bit, 1=1.5 bits, 2=2 bits
// Open COM port for reading
IF COM_Open(0, port, TRUE, FALSE) = FALSE THEN RETURN FALSE
// Set Baud rate and handshake
IF COM_SetComState(0, baud, parity, datab, stop) = FALSE THEN RETURN FALSE
RETURN TRUE
ENDFUNCTION

But all I get on the pandora is "failed" so it does not open the port (settings are correct). The terminal output is the following:
Quoteopenpandora:/media/PANDORA-SD/dev/sertest$ ./pandora-exe.pnd
timer
rbow
rbow init
sdl init video PANDORA
SDL_GetVideoInfo = 800x480 @ 16 bpp
800x480 sdl
get accurate timer - 1st call
flip - 1st call
BGRA ext supported
Texture size limit: 2048
init fbo
2D VP
OGRB init [OK]
Cptn
Network
Input
Window mode
Create DXin
reptr
getexe
cd
set cdir to: /media/PANDORA-SD/dev/sertest
exepath=curdir= /media/PANDORA-SD/dev/sertest
Init Finalized
open error 0 Success
Shut down GLB
glb is shut down
exit
Has anyone gotten a serial connection to work in Linux or has some experience with this? I have some C basics but I never programmed under linux so I have no Idea how to fix this.

MrTAToad

By the looks of it, dont think it was tested on Linux...

Ian Price

I've got a Pandora too, but no idea about Linux or serial ports so can't help with your code at all.

The Pandora generally has all USB ports turned off in the default menus. Perhaps the serial port is also turned off?
I came. I saw. I played.

Julian

No. The serial port is working with blue tooth (rfcomm0). A "picocom /dev/rfcomm0" works great. I figured that it was not tested under linux but I have never programmed in c under linux so I hope there is someone out here who has.