Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Julian

#1
I am using DDGui only for some specific parts of my application. That means that I sometimes use DDgui_msg() without an actual Dialog. The problem is that I can't set the color scheme without one. When I try to call for example DDgui_set("","COL_NORM",RGB(0,0,0)) the program just crashes. I know I could "hardcode" the colors but thats not a nice solution. Is there another way?
#2
Nice to hear the tool works good. I read a small article about it in a magazine but never tried it. If there is any interest in hooking APIs by hand I could write a small tutorial. But I don't know if
a. this is the right community (it has nothing to do with GLBasic)
b. my English is good enough
But if there is enough interest I can at least try.
#3
I've been using this tool for years. Its great. If you want the actual parameters you can try API Monitor. I haven't tested it though. I write my own API hooks if I need to intercept a call.
#4
DD-GUI / Re: font kerning
2012-Sep-30
Thanks you two. Using the version from my samples folder works fine.
#5
DD-GUI / font kerning
2012-Sep-29
I am building a simple gui for my project but font kerning does not work. The method "DDgui_UpdateFont(TRUE)" does not exist. At first I tried the version from the website: http://www.glbasic.com/showroom.php?site=games&game=DDgui which would not even compile. Searching for the Problem I found this updated version: http://www.glbasic.com/forum/index.php?topic=1868.msg13600#msg13600 but this too do not have this method. Where Can I find it? And is there a way to change the color scheme for the widgets?
#6
Ok just a quick status update. I ported the c code from post#1 1:1 to GLBasic INLINE and that is working. I copied all the necessary (type)defs/structs/function prototypes from the c/c++ Development Tools PND I use on the Pandora so there is a chance that this is the problem with the Code from Gernot (I didn't change/checked what was already implemented).
#7
I wouldn't need to modify it if it would work. The original code from the Thread I linked in Post #1 doesn't compile for the Pandora. I will try to port the C file 1:1 and I will try it with the new GLBasic V11 when I have some time for it.
#8
Ok I am pretty sure that this is a GLBasic Problem and not a C Problem so I will post this here. I am Trying to get this Serial Communication Lib to work under Linux (my Pandora to be exact). At first here is my working C code I am trying to port to GLBasic:
Code (glbasic) Select
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>
#include <unistd.h>

int fd1;
char buff[1];
int rd;

int main()
{
fd1=open("/dev/rfcomm0", O_RDWR | O_NOCTTY | O_NDELAY);
if (fd1 == -1 )
{
perror("open_port: Unable to open port");
}

else
{
fcntl(fd1, F_SETFL,0);
struct termios options;
tcgetattr(fd1, &options);
cfsetispeed(&options, B38400);
cfsetospeed(&options, B38400);
tcsetattr(fd1, TCSANOW, &options);
printf("Port has been sucessfully opened and %d is the file description\n",fd1);
}

while(1)
{
rd=read(fd1,buff,1);
printf("%s", buff);
}
close(fd1);
return 0;
}

This is my GLBasic Testcode:
Code (glbasic) Select
PRINT "Opening Serial Port....",0,0
SHOWSCREEN

IF comopen() = FALSE
PRINT "Failed",0,0
SHOWSCREEN
KEYWAIT
RETURN
ELSE
PRINT "Opened!",0,0
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$  = INIGET$("GPS","COMPORT","/dev/rfcomm0")
LOCAL baud   = INTEGER(INIGET$("GPS","BAUDRATE",38400))
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

I can open and read the Serial Port but only if I comment out the COM_SetComState command. Here are some important parts of my modified SerialPort Lib:
Code (glbasic) Select
FUNCTION COM_Open: iSlot%, port$, bRead, bWrite
INLINE
#ifdef WIN32
[...] //not relevant
#else
return (OpenAdrPort(iSlot, port_Str.c_str()) < 0) ? FALSE:TRUE;
#endif
ENDINLINE
ENDFUNCTION

[...]

FUNCTION COM_SetComState: iSlot%, baud, parity, databits, stopbits
INLINE
    #ifdef WIN32
   [...] //not relevant
    #else
    return (SetAdrPortMode(iSlot, baud) < 0) ? FALSE:TRUE;
    //SetAdrPortMode(iSlot, baud);
    // #NEED parity and shit
    #endif
ENDINLINE
ENDFUNCTION

[...]

int OpenAdrPort(int iSlot, const char* device)
{
    DGStr sPortName = device;

    // make sure port is closed
    //CloseAdrPort(iSlot);

    g_hSerialFile[iSlot] = open(device, O_RDWR | O_NOCTTY | O_NDELAY);
    if (g_hSerialFile[iSlot] < 0)
    {
        STDERR (CGStr("open error ")+DGNat(errno)+CGStr(" ")+CGStr(strerror(errno))+CGStr("\n"));
    }
    else
    {
    printf("%s opened\n", device);
    fcntl(g_hSerialFile[iSlot], F_SETFL,0);
    printf("file control changed\n", device);
    }
    printf("Returing file Pointer\n");
    return g_hSerialFile[iSlot];
}

[...]

int SetAdrPortMode(int iSlot, int baud)
{
if(g_hSerialFile[iSlot] != INVALID_HANDLE)
    {
    struct termios options;
    printf("read attributes\n");
tcgetattr(g_hSerialFile[iSlot], &options);
printf("set Input speed\n");
cfsetispeed(&options, B38400);
printf("set Output speed\n");
cfsetospeed(&options, B38400);
printf("set attributes\n");
tcsetattr(g_hSerialFile[iSlot], TCSANOW, &options);
return 0;
    }
    return -1;
}

This code results in a segfault. I was not able to pip out the output so I copied it from console. I attached it as log1.txt
What strange is, is that the program sets the attributes and then tries to read it again and then segfaults.
So I commented out the "cfsetospeed" and "cfsetispeed" lines (to see if I can read and write the attributes without modifying). Now the program doesn't sefault anymore but loops while setting up the serial device, returns FALSE after several attempts and I have no idea why. I was able to pipe out the bash output and attached it as log2.txt.
I have no idea where the segfault or the inifinte loop comes form. Any ideas from the more experienced programmers?

[attachment deleted by admin]
#9
Ok I know the title is bad but I can't think of anything better. I have the following situation:
I have a Menu with several options. You select one with the arrow keys and confirm with return (Key 28).
The problem is after one selection in the menu you directly have to enter some information (INPUT). Now the problem is that the INPUT is always 0 because I use the return key in the Menu. I tried something like this in the Menu
Code (glbasic) Select
IF KEY(28)
SELECT windowselection
[...]
ENDSELECT
WHILE KEY(28)
SLEEP 1
WEND
ENDIF

And in the actual window where the input happens:
Code (glbasic) Select
WHILE KEY(28)
SLEEP 1
WEND
INPUT myvar,0,0,TRUE

But this does not work. The only thing that works is doing a dummy input and then the real one. Any ideas how I can solve this problem?
#10
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.
#11
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.
#12
Inline / 3rd party / cURL
2011-Jun-11
Has anyone tried to use cURL with GLBasic? I'dont mean wrapping the libcurl.dll but using the library itself to compile directly into the Project (preferably cross compiling for multiple systems). I know some C basics but I have no idea of libraries and crosscompiling.

Julian
#13
I use Dropbox to synchronize my Project between my PC and my Netbook. I can't test ma GPS Application Indoors so I use my Netbook and change the code "on the go" (in my garden) if nessesary. When I go back to my Desktop PC I don't see the changes. Other programs (e.g. Notepad++, Visual Studio ...)  show a message like "The opened file "abc.xyz" has been changed. Would you like to reload the file?". Something like this with GLBasic would be great.

Kind regards
Julian
#14
Ich habe zwei Probleme mit Input:
1. Die Zeichenbreite ist zu groß (es gibt keine bKerning% Option wie bei Print)
2. Mit Return/Enter wird nur ein "gelbes Kästchen" gezeichnet, dies beendet aber nicht die Eingabe. Ich muss die Eingabe immer mit STRG+ENTER bestätigen.
Anbei ein Screenshot der das ganze erläutert.

Gruß Julian


[attachment deleted by admin]
#15
Die Genauigkeit der Formel liegt bei 0.5mm und orientiert sich am WGS 84 Elipsoid welcher die Erde beschreibt. Allerdings rechnet GLBasic nicht so genau (der gleiche Code in Python ist genauer). Wie gesagt ich hatte knapp 1cm Abweichung bei ~500km Distanz (das sind 2x10^-6% Abweichung). Das reicht für meine Zwecke vollkommen.

Gruß Julian