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

Topics - 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
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?
#3
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]
#4
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?
#5
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.
#6
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
#7
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
#8
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]
#9
Ich bastel gerade ein GPS Programm und da ist es immer gut die Distanz zwischen zwei Punkten zu wissen. Ich habe den Algorithmus von Thaddeus Vincenty mal nach GLBasic portiert. Ein Testergebnis von München nach Berlin war bei mir 9mm größer als das vom JavaScript (oder meinem alten Python Script). Aber ich denke bei ~500km ist eine Abweichung von 9mm vollkommen i.O. ;)
Code (glbasic) Select
FUNCTION distance#: lat1, lon1, lat2, lon2
//source: http://www.movable-type.co.uk/scripts/latlong-vincenty.html
    //WGS-84 ellipsiod
    LOCAL a1 = 6378137.0, b = 6356752.3142, f = 1/298.257223563
   
    LOCAL L = (lon2-lon1);
    LOCAL U1 = ATAN((1-f)*TAN(lat1),1)
    LOCAL U2 = ATAN((1-f)*TAN(lat2),1)
    LOCAL sinU1 = SIN(U1)
    LOCAL sinU2 = SIN(U2)
    LOCAL cosU1 = COS(U1)
    LOCAL cosU2 = COS(U2)
    LOCAL lambda = L
    LOCAL iterLimit = 100
    LOCAL lambdaP = 0
   
    LOCAL cosSqAlpha
    LOCAL sinSigma
    LOCAL cos2SigmaM
    LOCAL cosSigma
    LOCAL sigma
   
    WHILE (ABS(lambda-lambdaP) > 1e-12 AND iterLimit > 0)
    LOCAL sinLambda = SIN(lambda)
        LOCAL cosLambda = COS(lambda)
        sinSigma = SQR((cosU2 * sinLambda) * (cosU2 * sinLambda) + (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda) * (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda))
        IF sinSigma = 0 THEN RETURN 0
        cosSigma = sinU1 * sinU2 + cosU1 * cosU2 * cosLambda
        sigma = ATAN(sinSigma, cosSigma)
        LOCAL sinAlpha = cosU1 * cosU2 * sinLambda / sinSigma
        cosSqAlpha = 1 - sinAlpha * sinAlpha
        cos2SigmaM = cosSigma - 2 * sinU1 * sinU2 / cosSqAlpha
        IF NOT IsNumeric(cos2SigmaM) THEN cos2SigmaM = 0
        LOCAL C = f/16*cosSqAlpha*(4+f*(4-3*cosSqAlpha))
        lambdaP = lambda
        lambda = L + (1-C) * f * sinAlpha *(sigma + C*sinSigma*(cos2SigmaM+C*cosSigma*(-1+2*cos2SigmaM*cos2SigmaM)))
    WEND
    IF iterLimit = 0 THEN RETURN -1
    LOCAL uSq = cosSqAlpha * (a1*a1 -     b*b) / (b*b)
    LOCAL A2 = 1 + uSq/16384*(4096+uSq*(-768+uSq*(320-175*uSq)))
    LOCAL B = uSq/1024 * (256+uSq*(-128+uSq*(74-47*uSq)))
    LOCAL deltaSigma = B*sinSigma*(cos2SigmaM+B/4*(cosSigma*(-1+2*cos2SigmaM*cos2SigmaM)-B/6*cos2SigmaM*(-3+4*sinSigma*sinSigma)*(-3+4*cos2SigmaM*cos2SigmaM)))
    LOCAL s = b*A2*(deg2rad(sigma)-deltaSigma)
    RETURN s
ENDFUNCTION

IMPORT "C" double __stdcall atof(char*);

FUNCTION IsNumeric%: string$

INLINE
double t ;
t = atof( string_Str ) ;
if (t == (double) 0.0) // retval if atof() can't convert
return (DGNat) FALSE ;
return (DGNat) TRUE ;
ENDINLINE

ENDFUNCTION

FUNCTION deg2rad#: deg
LOCAL pi = 3.14159265358979
RETURN deg*pi/180
ENDFUNCTION

Evtl. kanns ja der Ein oder Andere gebrauchen.

Gruß Julian
#10
Ich habe gerade mein GPS Programm mit meinem Tablet (WeTab mit Windows 7) getestet. Dabei ist mir aufgefallen, dass das Programm immer den Mauszeiger fängt. Dieser wird dann unsichtbar, man kann ihn zwar noch bewegen, aber nichts mehr anklicken (außerhalb des GLBasic Programms). Auf meinem Desktop PC ist mir das nie aufgefallen, denn da hab ich das Programm einfach via Alt+Tab gewechselt und schon war der Mauszeiger in vollem Umfang wieder da. Auf einem Tablet ohne Tastatur ist das nicht so einfach ;). Gibts ne Möglichkeit, dass der Mauszeiger im Fenstermodus nicht gefangen wird (so wie bei fast jedem Spiel im Fenstermodus)?

Gruß Julian
PS: Der deutsche Bereich hier im Forum ist ja recht dünn besiedelt, evtl. sollte ich da lieber auf den englischen Bereich überschwenken.
#11
Ich habe mit UO DiNGSFont eine Font erstellt (das Problem Betrifft auch das normale DiNGSFont Tool deshalb als separater Thread). Jedoch ist der Abstand zwischen den Buchstaben viel zu groß. Ein Beispiel ist als Screenshot angehängt. Wie kann ich dieses Problem lösen?

Gruß Julian

[attachment deleted by admin]
#12
Ich weiß nicht, ob es hier üblich bzw. erwünscht ist, sich vorzustellen, aber ich mache es trotzdem. Ich finde wenn man einer neuen Community Beitritt ist es immer schön ein bisschen was von sich zu erzählen.
Mein Name ist Julian (oh welch großes Wunder), ich bin 20 Jahre alt, komme aus Bayern und studiere Ingenieurinformatik (2. Semester).
Ich habe mit ca. 15 Jahren das Programmieren angefangen. Damals noch mit Visual Basic 6. Dann kam VB.net und Python. Im Studium lernen wir C.
Ich bin vor Jahren schon mal auf GLBasic gestoßen (welcher Jugendliche möchte nicht sein eigenes Spiel?), doch das habe ich dann recht schnell wieder aufgegeben.
Jetzt, einige Jahre später sind meine Ziele niedriger und mein Einschätzungsvermögen besser. Ich suche v.A. nach einer Möglichkeit Programme für die Pandora zu schreiben, ohne großartig Crosscompiler und Toolchains einrichten zu müssen. Leider besitze ich selbige noch nicht (Vorbestellt im Oktober 09), dennoch möchte ich mich schon vorher in GLBasic einarbeiten. Mein erstes Projekt wird eine minimale Geocaching Applikation. Diese habe ich bereits vor längerer Zeit in Python geschrieben, doch ich habe keine Ahnung, wie gut das auf der Pandora laufen würde (evtl. Probleme mit den Modulen etc...). Ich bin jetzt also dabei das ganze Stück für Stück zu portieren und gleichzeitig zu verbessern.

Gruß Julian