|
Post by bigbass on May 13, 2021 19:45:22 GMT 1
|
|
|
Post by rikky on May 14, 2021 7:40:22 GMT 1
Yes, your canvas program works. But I cannot load an svg in it. Which I need for the charts.
The svg_event_box however, puts a smaller svg image in the box, but still centered around the box center. Hence the recalculation.
svg offers a viewbox with which you can zoom, and walk away. Nice feature for a chart program. So I improved the demo with a zoom of 0.8 and x and y of 10
Third attemt to upload the program I will not do. My browser now crashed twice after pressing the upload button for some reason.
program:
version$ = "0.3"
INCLUDE "hug.bac"
OPTION EXPLICIT TRUE
GLOBAL EVENT_SVGIMG_HIGHT = 300 GLOBAL EVENT_SVGIMG_WIDTH GLOBAL EVENT_SVGIMG_RADIUS GLOBAL window GLOBAL myimg1 GLOBAL click_svg$ GLOBAL ball$ = "<svg width='10' height='10' viewBox='0 0 10 10'><circle cx='5' cy='5' r='5' stroke='black' stroke-width='2' fill='magenta' /></svg>" GLOBAL CENTER GLOBAL GRIDSTEP
DECLARE SVG_ZOOM TYPE float GLOBAL VIEWBOX_WIDTH GLOBAL VIEWBOX_HIGHT GLOBAL VIEWBOX_X = 10 GLOBAL VIEWBOX_Y = 10
SVG_ZOOM = 0.8
EVENT_SVGIMG_WIDTH = EVENT_SVGIMG_HIGHT EVENT_SVGIMG_RADIUS = EVENT_SVGIMG_HIGHT/2 CENTER = EVENT_SVGIMG_RADIUS GRIDSTEP = EVENT_SVGIMG_HIGHT/10
IF TOKEN$(ARGUMENT$,2) <> "" THEN IF VAL(TOKEN$(ARGUMENT$,2)) != 0 THEN SVG_ZOOM = VAL(TOKEN$(ARGUMENT$,2)) END IF END IF
VIEWBOX_WIDTH = ROUND(SVG_ZOOM * EVENT_SVGIMG_WIDTH) VIEWBOX_HIGHT = ROUND(SVG_ZOOM * EVENT_SVGIMG_HIGHT)
GLOBAL HUG_Gtk$ = HUGLIB$("gtk") GLOBAL HUG_Gdk$ = HUGLIB$("gdk") GLOBAL HUG_Rsvg$ = "librsvg-2.so" GLOBAL HUG_Gdkpixbuf$ = hug_Get_Gdkpixbuf$()
IMPORT "gtk_image_set_from_pixbuf(long,long)" FROM HUG_Gtk$ TYPE void IMPORT "gtk_widget_get_toplevel(long)" FROM HUG_Gtk$ TYPE long
IMPORT "gdk_pixbuf_loader_new()" FROM HUG_Gdk$ TYPE long IMPORT "gdk_pixbuf_loader_write(long,unsigned char*, long int, int)" FROM HUG_Gdk$ TYPE int IMPORT "gdk_pixbuf_loader_close(long,int)" FROM HUG_Gdk$ TYPE int IMPORT "gdk_pixbuf_loader_get_pixbuf(long)" FROM HUG_Gdk$ TYPE long
'sudo apt-get install librsvg2-dev IMPORT "rsvg_init()" FROM HUG_Rsvg$ TYPE void IMPORT "rsvg_term()" FROM HUG_Rsvg$ TYPE void IMPORT "rsvg_handle_new()" FROM HUG_Rsvg$ TYPE long IMPORT "rsvg_handle_write(long,char*,long,int)" FROM HUG_Rsvg$ TYPE int IMPORT "rsvg_handle_close(long,int)" FROM HUG_Rsvg$ TYPE int IMPORT "rsvg_handle_get_pixbuf(long)" FROM HUG_Rsvg$ TYPE long IMPORT "gtk_image_new_from_pixbuf(long)" FROM HUG_Gtk$ TYPE long IMPORT "gdk_pixbuf_get_width(long)" FROM HUG_Gdkpixbuf$ TYPE int IMPORT "gdk_pixbuf_get_height(long)" FROM HUG_Gdkpixbuf$ TYPE int
IMPORT "gtk_window_set_icon(long,long)" FROM HUG_Gtk$ TYPE void
FUNCTION EVENT_SVGIMAGE(STRING svg$, STRING widget_name$, int hug_xsize, int hug_ysize)
LOCAL myimage, ebox, mysvg, ok, mypix rsvg_init() mysvg = rsvg_handle_new() ok = rsvg_handle_write(mysvg, svg$, LEN(svg$), 0) ok = rsvg_handle_close(mysvg, 0) mypix = rsvg_handle_get_pixbuf(mysvg) g_object_unref(mysvg) rsvg_term() myimage = gtk_image_new_from_pixbuf(mypix) g_object_unref(mypix) ebox = gtk_event_box_new() ' add image to event box gtk_container_add(ebox, myimage) gtk_widget_set_events(ebox, GDK_POINTER_MOTION_MASK | GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_SCROLL_MASK) g_signal_connect_data(ebox, "button-press-event", hug_mouse_event, 20, 0, 0) g_signal_connect_data(ebox, "button-release-event", hug_mouse_event, 0, 0, 0) g_signal_connect_data(ebox, "motion-notify-event", hug_mouse_event, 0, 0, 0) g_signal_connect_data(ebox, "leave-notify-event", hug_mouse_event, 30, 0, 0) IF HUG_WIDGET_SHOW THEN gtk_widget_show_all(ebox) END IF hug_widget_xsize(STR$(ebox)) = hug_xsize hug_widget_ysize(STR$(ebox)) = hug_ysize hug_widget_s_widget(STR$(ebox)) = ebox hug_widget_signal(STR$(ebox)) = 4 hug_widget_type$(STR$(ebox)) = "image" hug_widget_font(STR$(ebox)) = myimage hug_widget_focus(STR$(ebox)) = myimage hug_widget_image$(STR$(ebox)) = widget_name$ RETURN ebox END FUNCTION
FUNCTION SVG_PUT(NUMBER hug_widget, STRING svg$) LOCAL pixloader, pixbuf TYPE long LOCAL size TYPE NUMBER LOCAL i, res TYPE int LOCAL image size = LEN(svg$) LOCAL raw_array TYPE unsigned char* size = LEN(svg$) raw_array = (unsigned char*)svg$ image = hug_widget_font(STR$(hug_widget)) pixloader = gdk_pixbuf_loader_new()
'here it is 'occasional segfault error '=> res = gdk_pixbuf_loader_write(pixloader, raw_array, size, 0) res = gdk_pixbuf_loader_close(pixloader, 0) pixbuf = gdk_pixbuf_loader_get_pixbuf(pixloader) gtk_image_set_from_pixbuf(image, pixbuf) 'g_object_unref(pixbuf) gtk_widget_queue_draw(image) hug_widget_image$(STR$(hug_widget)) = "svg" 'new g_object_unref(pixbuf) RETURN pixbuf END FUNCTION
FUNCTION SVG_BUFF(STRING svg$)
LOCAL pixloader, pixbuf TYPE long 'LOCAL pixloader TYPE GdkPixbufLoader* 'LOCAL pixbuf TYPE GdkPixbuf* LOCAL size TYPE NUMBER LOCAL res TYPE int LOCAL raw_array TYPE unsigned char* size = LEN(svg$) raw_array = (unsigned char*)svg$ pixloader = gdk_pixbuf_loader_new() res = gdk_pixbuf_loader_write(pixloader, raw_array, size, 0) res = gdk_pixbuf_loader_close(pixloader, 0) pixbuf = gdk_pixbuf_loader_get_pixbuf(pixloader) RETURN pixbuf END FUNCTION
SUB SET_WINICON(long widget, STRING svg$) ' set tray icon for application using inline svg string LOCAL pix pix = SVG_BUFF(svg$) gtk_window_set_icon(gtk_widget_get_toplevel(widget), pix) g_object_unref(pix) END SUB
FUNCTION CALCULATE_SVG_MOUSEPOS(int pos,int event_svg_image_size) 'recalculate the position in an EVENT_SVGIMAGE box 'event_svg_image_size represents either event_svg_image_xsize or event_svg_image_ysize LOCAL newpos LOCAL difference LOCAL center center = ROUND(event_svg_image_size/2) newpos = center - ROUND((center - pos/1.2)/25*30) IF newpos < 0 THEN newpos = -1 IF newpos > center * 2 THEN newpos = (center *2)+ 1 RETURN newpos END FUNCTION
FUNCTION rect_svg$() LOCAL string$ 'LOCAL grid$ LOCAL i string$ = "<rect width='" & STR$(EVENT_SVGIMG_WIDTH) & \ "' height='" & STR$(EVENT_SVGIMG_HIGHT) & "' " & \ "style='fill:rgb(0,0,255);stroke-width:3;stroke:rgb(0,0,0)' />" & NL$ string$ = string$ & "<circle cx='" & STR$(EVENT_SVGIMG_RADIUS) & "' cy='" & STR$(EVENT_SVGIMG_RADIUS) & "' r='" & STR$(EVENT_SVGIMG_RADIUS) & "' " & "fill='green' />" & NL$ string$ = string$ & "<circle cx='" & STR$(EVENT_SVGIMG_RADIUS) & "' cy='" & STR$(EVENT_SVGIMG_RADIUS) & "' r='10' fill='red' />" & NL$ FOR i = GRIDSTEP TO EVENT_SVGIMG_WIDTH STEP GRIDSTEP string$ = string$ & \ "<line x1='" & STR$(i) & "' y1='0' x2='" & STR$(i) & "' y2='" & STR$(EVENT_SVGIMG_HIGHT) & "' stroke='black' stroke-width='1' />" & NL$ string$ = string$ & \ "<line x1='0' y1='" & STR$(i) & "' x2='" & STR$(EVENT_SVGIMG_WIDTH) & "' y2='" & STR$(i) & "' stroke='black' stroke-width='1' />" & NL$
NEXT i RETURN string$ END FUNCTION
FUNCTION svg_image$() LOCAL string$ string$ = "<svg width='" & STR$(EVENT_SVGIMG_WIDTH) & \ "' height='" & STR$(EVENT_SVGIMG_HIGHT) & \ "' viewBox='" & STR$(VIEWBOX_X) & " " & STR$(VIEWBOX_Y) & " " & \ STR$(VIEWBOX_WIDTH) & " " & STR$(VIEWBOX_HIGHT) & \ "'><g>" & rect_svg$() & click_svg$ & "</g></svg>" RETURN string$ END FUNCTION
SUB GUI window = WINDOW("ball",EVENT_SVGIMG_WIDTH,EVENT_SVGIMG_HIGHT) myimg1 = EVENT_SVGIMAGE(svg_image$(),"ball",EVENT_SVGIMG_WIDTH,EVENT_SVGIMG_HIGHT) SET_WINICON(window,ball$)
ATTACH(window, myimg1, 0,0) CALLBACK(myimg1, MOUSE_CLICK) SYNC END SUB
FUNCTION MOUSE_EVENT() LOCAL POS_X$ LOCAL POS_Y$ POS_X$ = STR$(ROUND(CALCULATE_SVG_MOUSEPOS(MOUSE(0),EVENT_SVGIMG_WIDTH)*SVG_ZOOM)) POS_Y$ = STR$(ROUND(CALCULATE_SVG_MOUSEPOS(MOUSE(1),EVENT_SVGIMG_WIDTH)*SVG_ZOOM)) IF VAL(POS_X$) > EVENT_SVGIMG_WIDTH THEN POS_X$ = STR$(EVENT_SVGIMG_WIDTH + 1) IF VAL(POS_Y$) > EVENT_SVGIMG_HIGHT THEN POS_Y$ = STR$(EVENT_SVGIMG_HIGHT + 1) IF VAL(POS_X$) < 0 THEN POS_X$ = "-1" IF VAL(POS_Y$) < 0 THEN POS_Y$ = "-1" POS_X$ = STR$(VAL(POS_X$) + VIEWBOX_X) POS_Y$ = STR$(VAL(POS_Y$) + VIEWBOX_Y) GOTOXY 1,4 PRINT PRINT "EVENT" PRINT "# POS_X: ", POS_X$,"<- " PRINT "# POS_Y: ", POS_Y$,"<- " RETURN TRUE END FUNCTION
SUB MOUSE_CLICK()
LOCAL POS_X$ LOCAL POS_Y$ POS_X$ = STR$(ROUND(CALCULATE_SVG_MOUSEPOS(MOUSE(0),EVENT_SVGIMG_WIDTH)*SVG_ZOOM)) POS_Y$ = STR$(ROUND(CALCULATE_SVG_MOUSEPOS(MOUSE(1),EVENT_SVGIMG_WIDTH)*SVG_ZOOM)) IF VAL(POS_X$) > EVENT_SVGIMG_WIDTH THEN POS_X$ = STR$(EVENT_SVGIMG_WIDTH + 1) IF VAL(POS_Y$) > EVENT_SVGIMG_HIGHT THEN POS_Y$ = STR$(EVENT_SVGIMG_HIGHT + 1) IF VAL(POS_X$) < 0 THEN POS_X$ = "-1" IF VAL(POS_Y$) < 0 THEN POS_Y$ = "-1" POS_X$ = STR$(VAL(POS_X$) + VIEWBOX_X) POS_Y$ = STR$(VAL(POS_Y$) + VIEWBOX_Y) GOTOXY 1,20 PRINT PRINT "CLICK" PRINT "# POS_X: ", POS_X$," " PRINT "# POS_Y: ", POS_Y$," " click_svg$ = "<circle cx='" & POS_X$ & \ "' cy='" & POS_Y$ & \ "' r='5' stroke='black' " & \ "stroke-width='3' fill='magenta' />"
SVG_PUT(myimg1,svg_image$()) SYNC END SUB
CURSOR OFF CLEAR
GUI TIMEOUT(1,MOUSE_EVENT) DISPLAY
Some issues is that if you add a lot of buttons and rings and bells, the program segfaults sometimes at line 123
I beleve this has something to do with an other even more rare error:
Or that the svg is not beeing closed propperly before you load a new one, like as is explained somewhere in the Gui proxy for BaCon thread.
But that is for later.
Rik
|
|
|
Post by rikky on May 15, 2021 10:29:26 GMT 1
Don't ask me why or how, but implementing the recalculation of the svg-cursor in OpenSeaGui suddenly was not necessary anymore. It works now with the original MOUSE() did not change nothing though. Okee, got something ready. Except the two most difficult things. 1) a segfault after some time in line 154 of hug_extra.bac in function SVG_PUT(NUMBER hug_widget, STRING svg$) FUNCTION SVG_PUT(NUMBER hug_widget, STRING svg$) LOCAL pixloader, pixbuf TYPE long LOCAL size TYPE NUMBER LOCAL i, res TYPE int size = LEN(svg$) LOCAL raw_array TYPE unsigned char* size = LEN(svg$) raw_array = (unsigned char*)svg$ image = hug_widget_font(STR$(hug_widget)) pixloader = gdk_pixbuf_loader_new()
'here it is 'occasional segfault error '=> res = gdk_pixbuf_loader_write(pixloader, raw_array, size, 0) res = gdk_pixbuf_loader_close(pixloader, 0) pixbuf = gdk_pixbuf_loader_get_pixbuf(pixloader) gtk_image_set_from_pixbuf(image, pixbuf) 'g_object_unref(pixbuf) gtk_widget_queue_draw(image) hug_widget_image$(STR$(hug_widget)) = "svg" 'new g_object_unref(pixbuf) RETURN pixbuf END FUNCTION And 2) The memory walks full or something, for after a while (if no segfault) the computer slacks, until it freezes and a hard reset is needed. Both issues are neck breakers. All this effort is in vain, if these problems are not solved. And honestly , from here it all goes a little above my hat. Anyway, The next OpenSeagui demo 2 spinners , one for Tyle zoom, and one for svg zoom UP,DOWN,LEFT,RIGHT buttons for moving the chart position. (sinds a mouse continue press is not recognised by HUG) a rectangle button for putting your chart position back to the own ship position. I hope it al works, for I made some last minute changes (as usual) 5.tgz (63.86 KB) Rik.
|
|
|
Post by rikky on May 16, 2021 6:12:42 GMT 1
So i guess that was it. I did my best, and made something that is quicker then OpenCpn on a Raspi3 It has everything that is needed in it. The buttons to move the chart, could easily be translated in a grab hand once the MOUSE(3) button also recognises if the button is perma clicked. A third svg layer could be added also with your own notes. The shape of the boats could be improved in some triangle directing in the right course. you name it. Only it doesn't work. I've looked on the internet, how other people do this, and they do this mostly with HTML and JS., and then send it with a server. All the routines are already there, just cut and past. Since nobody seems to be interested here in a chart program (could be for canoes or bikes or hikers also), or improving GUI methods that actually work, I'll be moving on. I've got a steep learning curve ahead. Thanks for all the help nonetheless. Rik.
|
|
|
Post by rikky on May 16, 2021 18:35:10 GMT 1
Well, just in case AlexFish wakes up from the dead. Adapt a little on the programs MakeChart and GetBoats . Throw away the OpenSeaGui completely. (a couple of months of work) And then have your server throw up the resulting chart.svg with the following html page: Content-type: text/html
<!DOCTYPE html> <html> <head> <meta charset='UTF-8'> <meta name='viewport' content='width=device-width, user-scalable=yes, initial-scale=1.0'> <!--[if lt IE 9]> <script src='https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js'></script> <![endif]--> </head> <body style='background-color:CornflowerBlue; max-width:98%; max-height:100%;'> <div id='message' name='message'> </div> <BR> <div style='background-color:Bisque; text-align:center; border-radius:10%; margin:1%;'> <BR> <em> <h1> ChartPlotter </h1> </em> <BR> <BR> <div id='chart' name='chart' style ='text-align:center; border-radius:5%; '> </div> <BR> <BR> </div> <BR>
<script> function loadDoc() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById('chart').innerHTML = this.responseText; } }; xhttp.open('GET', 'chart.svg', true); xhttp.send(); } </script>
<script> function myTimer() { var d = new Date(); document.getElementById('message').innerHTML = d.toLocaleTimeString(); loadDoc(); } </script>
<script> var myVar = setInterval(myTimer, 1000); </script>
</body> </html>
Works already like a sharm Flawlessly, no flickering , smoothly. jquery.js can then be used for the mousefunctions and voila. No more rsvg_handle_new() or gdk_pixbuf_loader_close() or g_object_unref(pixbuf) and other completely uncomprehensible shit that only works because you cutted and pasted it precisely in a certain context, but as soon as it doesn't work you lose weeks and weeks and weeks of work, and still do not even begin to understand why. As if there aren't better ways to spend your time. I'm sorry to say, but I use BaCon for it's simplicity. Bacon Gui making however is NOT simple. And I won't make this mistake again. Rik.
|
|
|
Post by alexfish on May 16, 2021 20:47:25 GMT 1
Ah... Yawn
Been back 2 weeks , been going trough some bits. Like, What I dont like in some apps and what like....
hopeful, will have something in concrete , not 'set concrete' though, for testing
in mean time , feel free to post what ever , we all learn something new every day,
- of what gets posted is in generally useful here and possible for others that pass by
Thanks to Rik and All
BR Alex
|
|
|
Post by rikky on Jun 12, 2021 7:45:23 GMT 1
Most important for a navigation app is to realise that you're mostly offline. Since it is very difficult to roll out a lan cable behind your boat, and roll it back up on your way home, or have a gsm connection in the middle of nowhere, not to mention the costs (of roaming). There are various javascript possibilities out there and they have one thing in common. They are all incredibly complex. Solution is to serve a little BaCon cgi script instead of the street- or sea-map server, that checks if you have the requested chart available. If so, it serves the chart, if not it gets it from the internet, stashes it on your local computer, and then serve it. All you have to do is make your desired voyage already at home (connected to the net), in the desired zoomlevel(s). This could also be scripted, if you like. The Bacon tiles server is remarkably short, compared to the JS rubbish that is available out there. SEA_SERVER: GLOBAL pic$ GLOBAL REQUEST_URI$ GLOBAL command$ = ""
silent$ = "--silent" REQUEST_URI$ = GETENVIRON$("REQUEST_URI") amount = AMOUNT(REQUEST_URI$,"/") tile$ = "/" & TOKEN$(REQUEST_URI$,amount-2,"/") & "/" & TOKEN$(REQUEST_URI$,amount-1,"/") & "/" & TOKEN$(REQUEST_URI$,amount,"/") request_uri$ = "sea_tiles" & tile$
IF NOT(FILEEXISTS(request_uri$)) THEN command$ = "curl " & silent$ & " https://tiles.openseamap.org/seamark" & tile$ & " --output " & request_uri$ MAKEDIR DIRNAME$(request_uri$) SYSTEM command$ END IF
pic$ = request_uri$
PRINT "Content-Length: " & STR$(FILELEN(pic$)) PRINT "Content-Type: image/png" PRINT ""
SYSTEM "cat " & pic$
All ready as a minimalist template to be served by Apache2 server (see readme): seachart.tgz (89 KB) Finaly something that is usable. further adaptions are desirable, but luxury. Rik.
|
|
|
Post by alexfish on Jun 13, 2021 13:04:06 GMT 1
Hi Rik looks useful , will test soon Update: having a few problems , equipment wise , gps/ais unit went down soon after last post now have new , this one is wifi 'wireless' works in opencpn. so tried bacon tcp the module works stand alone 'sort of' , + have problem getting it to work with the app .. looking further Good side of things have done a c version 'looking good' , hence looking further as to baconising: end result should be connect at dev/tty + net connect also delayed due to installing new wiring and equipment 'seem to take forever' Back Soon BR Alex my gps/ais is on 192.168.1.100:2000 Bacon CodeOPEN "192.168.1.100:2000" FOR NETWORK AS mynet OPEN "192.168.1.100:2000" FOR NETWORK AS mynet SEND "GET / HTTP/1.1\r\nHost: 192.168.1.100:2000\r\n\r\n" TO mynet WHILE 1 DO RECEIVE dat$ FROM mynet PRINT dat$ ' can't do a sleep here so app will take the system WEND CLOSE NETWORK mynet the c version #include <sys/time.h> #include <stdio.h> //printf #include <string.h> //strlen #include <sys/socket.h> //socket #include <arpa/inet.h> //inet_addr #include <unistd.h> //usleep #include <fcntl.h> //fcntl
//Size of each chunk of data received, try changing this #define CHUNK_SIZE 512
//Receiving function int recv_timeout(int s, int timeout);
int main(int argc , char *argv[]) { int socket_desc; struct sockaddr_in server; char *message , server_reply[2000]; //Create socket socket_desc = socket(AF_INET , SOCK_STREAM , 0); if (socket_desc == -1) { printf("Could not create socket"); }
server.sin_addr.s_addr = inet_addr("192.168.1.100"); server.sin_family = AF_INET; server.sin_port = htons( 2000 );
//Connect to remote server if (connect(socket_desc , (struct sockaddr *)&server , sizeof(server)) < 0) { puts("connect error"); return 1; } puts("Connected\n"); //Send some data message = "GET /?st=1 HTTP/1.1\r\nHost: 192.168.1.100\r\n\r\n"; if( send(socket_desc , message , strlen(message) , 0) < 0) { puts("Send failed"); return 1; } puts("Data Send\n"); //Now receive full data int total_recv = recv_timeout(socket_desc, 4); printf("\n\nDone. Received a total of %d bytes\n\n" , total_recv); return 0; }
/* Receive data in multiple chunks by checking a non-blocking socket Timeout in seconds */ int recv_timeout(int s , int timeout) { int size_recv , total_size= 0; struct timeval begin , now; char chunk[CHUNK_SIZE]; double timediff; //make socket non blocking fcntl(s, F_SETFL, O_NONBLOCK); //beginning time gettimeofday(&begin , NULL); while(1) { gettimeofday(&now , NULL); //time elapsed in seconds timediff = (now.tv_sec - begin.tv_sec) + 1e-6 * (now.tv_usec - begin.tv_usec); //if you got some data, then break after timeout if( total_size > 0 && timediff > timeout ) { break; } //if you got no data at all, wait a little longer, twice the timeout else if( timediff > timeout*2) { break; } memset(chunk ,0 , CHUNK_SIZE); //clear the variable if((size_recv = recv(s , chunk , CHUNK_SIZE , 0) ) < 0) { //if nothing was received then we want to wait a little before trying again, 0.1 seconds usleep(100000); } else { total_size += size_recv; printf("%s" , chunk); //reset beginning time gettimeofday(&begin , NULL); } } return total_size; }
|
|
|
Post by alexfish on Jun 13, 2021 18:27:15 GMT 1
Just an update on the wifi looks like the data is arriving in blocks, so just need to split the block & then decode bacon code now simple, OPEN "192.168.1.100:2000" FOR NETWORK AS mynet SEND "GET / HTTP/1.1\r\nHost: 192.168.1.100:2000\r\n\r\n" TO mynet WHILE 1 DO RECEIVE dat$ FROM mynet dat$ = CHOP$(dat$) PRINT dat$ SLEEP (1) WEND CLOSE NETWORK mynet
BR Alex Sample from the terminal $GPRMC,172251.00,A,5457.94687,N,00134.33240,W,0.038,,130621,,,A*6B $GPVTG,,T,,M,0.038,N,0.070,K,A*2F $GPGGA,172251.00,5457.94687,N,00134.33240,W,1,11,0.92,7.1,M,48.1,M,,*4B $GPGSA,A,3,17,01,03,28,32,21,22,19,31,14,04,,1.47,0.92,1.15*09 $GPGSV,4,1,13,01,64,117,37,03,79,222,27,04,23,175,33,06,03,293,*7F $GPGSV,4,2,13,12,01,000,,14,08,248,37,17,53,280,37,19,34,307,33*7D $GPGSV,4,3,13,21,43,122,48,22,69,083,41,28,16,264,37,31,09,088,23*77 $GPGSV,4,4,13,32,15,038,33*45 $GPGLL,5457.94687,N,00134.33240,W,172251.00,A,A*7E $GPRMC,172252.00,A,5457.94693,N,00134.33241,W,0.048,,130621,,,A*6B $GPVTG,,T,,M,0.048,N,0.088,K,A*2F $GPGGA,172252.00,5457.94693,N,00134.33241,W,1,11,0.92,7.2,M,48.1,M,,*4F $GPGSA,A,3,17,01,03,28,32,21,22,19,31,14,04,,1.47,0.92,1.15*09 $GPGSV,4,1,13,01,64,117,37,03,79,222,28,04,23,175,33,06,03,293,*70 $GPGSV,4,2,13,12,01,000,,14,08,248,37,17,53,280,35,19,34,307,36*7A $GPGSV,4,3,13,21,43,122,46,22,69,083,41,28,16,264,37,31,09,088,20*7A $GPGSV,4,4,13,32,15,038,32*44 $GPGLL,5457.94693,N,00134.33241,W,172252.00,A,A*79 Update : then I find 'other spanner in the works' this is periodic if ais signal not in range :No valid AIS signal.
|
|
|
Post by rikky on Jun 14, 2021 5:44:09 GMT 1
gpsdecode -d gives: These are some satellites apparently. The rest is somewhere further. Looks good, No need for SignalK.
|
|
|
Post by rikky on Jun 19, 2021 12:49:56 GMT 1
We are not there yet. now working with openplotter on a raspi3 Which is basically an adapted Buster on a raspi3 The Raspi4's (I now have 2) are in use somewhere else. The Raspi3 is for testing. So I have my app, that I can control now nearly totally. i can see charts, boats, and download my charts for offline use. Nice. Untill I unplug the router to the outside world. Which, if you want to go out sailing, is mandatory. My localhost does not work anymore. Nothing works anymore. Not one single raspy on the local network is reachable. BaconServer, none of them work. only SignalK is reachable via http://localhost:3000/etc So they have invented something to solve this. But they have no folder to put your html files in, let alone a cgi script. ghha .....
|
|
|
Post by rikky on Jun 20, 2021 8:59:03 GMT 1
Solved. This wasn't a Bacon nor Linux thing at all. This is something weird with the router. Disconnecting the outside world internet isn't enough. You have to disconnect the whole router out of the system for some strange reason. Now the local network is back.
|
|
|
Post by rikky on Jun 21, 2021 14:40:35 GMT 1
I'm using leaflet.js (thanks Bigbass) And leaflet.js can use svg icons. So instead of a circle for a boat, we can also use a triangle, pointing to the direction of the ships course. That is if your speed is somewhat above zero. The standard way of getting an icon for leaflet however is to get the svg from a file. But since we do not know what the course is in advance, we do not have the right svg in a file. there are various ways to go around this, and they all involve a lot of Jscript. So again BaCon comes to the rescue. Just point your svg-image to a BaCon.svg cgi script. In template.html instead of the circle: var boat_icon= L.icon({ iconUrl: 'svg/triangle.svg?'+course, iconSize: [20, 20], }); boat[i]=L.marker([latitude,longitude],{ icon:boat_icon }); The cgi program is called triangle.svg.bac: course$ = GETENVIRON$("QUERY_STRING")
'translate radials to degrees PRINT VAL(course$) * 180 / PI FORMAT "%.10f" TO course$
pic$ = \ "<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='-50 -50 100 100'>" & NL$ & \ " <polygon style='fill:lime;stroke:purple;stroke-width:1' transform='rotate(" & course$ & ")' points='-25,50 0,25 25,50 0,-50'/>" & NL$ & \ "</svg>" PRINT "Content-Length: " & STR$(LEN(pic$)) PRINT "Content-Type: image/svg+xml" PRINT ""
PRINT pic$ And then you get nothing because the server doesn't understand that it should handle this file as a cgi script. .htaccess: (for Apache server) <FilesMatch "triangle.svg"> SetHandler cgi-script </FilesMatch>
done.. Next step : clicking right click to incorporate an info icon ( I). For example to incorporate vhf-channel and telephone-number of a lock, , tide (extra script for the tides?) etc.. Next Next step is plotting your route Next Next Next step is plotting your route in advance so the thing downloads the necessary charts, when you are online. Next Next Next Next step ... etc. This thing is now way beyond OpenCpn. And also beyond the demo leaflet chart of SignalK. That thing doesn't do offline charts. (but it looks better, but that is luxury) Thanks to all people that helped making this nav_app: Vovchick, Bigbass and above all Alexfish. Thanks to Vovchick for the svg help. Thanks to Pjotr for BaCon. Rik.
|
|
|
Post by rikky on Jun 21, 2021 14:51:30 GMT 1
Pity I don't sail anymore.
|
|
|
Post by vovchik on Jun 21, 2021 15:03:39 GMT 1
Dear Rik,
Thanks. And it's a pity I don't sail these days either. Although I used to. There is nothing quite like being out on the sea and knowing when and what to do with the lines, boom and tiller...and reaching your destination, crew and boat intact. Dealing with nature in real time is the fun and challenging part.
With kind regards, vovchik
|
|