Go to advanced search

by Garethmoffatt
Thu Jan 03, 2019 3:09 am
Forum: C/C++
Topic: How to get CPU load in C
Replies: 15
Views: 1851

Re: How to get CPU load in C

IMO, it doesn’t matter how you get a result, provided it is the right result. Personally I wouldn’t run the load calculation in a separate thread because that looks like more effort than it is worth. The overhead of the calculation is so low that it is not worth splitting in to a separate core. On t...
by Garethmoffatt
Wed Jan 02, 2019 3:55 am
Forum: Graphics programming
Topic: Guidance debugging GTK-3 Application
Replies: 2
Views: 929

Re: Guidance debugging GTK-3 Application

Could be, suggestions for finding it?
by Garethmoffatt
Mon Dec 31, 2018 11:50 pm
Forum: C/C++
Topic: How to get CPU load in C
Replies: 15
Views: 1851

Re: How to get CPU load in C

Here is a code fragment from a program that I wrote. It is only a fragment because mine was a GTK graphical representation of load and that is more than you were asking for.... long a[9]; long up[5], up1[5], idle[5], idle1[5]; gint processors = 4; static gboolean one_second_timer_cb(gpointer data) /...
by Garethmoffatt
Mon Dec 31, 2018 2:51 pm
Forum: Graphics programming
Topic: Guidance debugging GTK-3 Application
Replies: 2
Views: 929

Guidance debugging GTK-3 Application

I need some guidance on how to go about debugging a GTK application I have been working on. It is a graphical front end to an Arduino that is collecting data (primarily from a GPS) and then displaying it with the GTK widgets. It is a project that I work on part time at the weekends, has been under d...
by Garethmoffatt
Mon Nov 26, 2018 4:54 am
Forum: Graphics programming
Topic: gtk_combo_box_text_remove_all causes segmentation fault
Replies: 1
Views: 3277

Re: gtk_combo_box_text_remove_all causes segmentation fault [solved]

Turns out there was no problem with the library (no real surprise!) The error was a self inflicted wound! For each element, as the box is emptied, the call back that I had registered for combo box change is called. In that I was getting the active selection with out checking that the result was != n...
by Garethmoffatt
Sat Jul 14, 2018 9:40 pm
Forum: Graphics programming
Topic: [solved] Ensuring gtk_application is unique
Replies: 1
Views: 1144

Re: Ensuring gtk_application is unique

Ok, so nobody wanted to come up with a solution, so I did it using a named semaphore.

Best regards

Gareth
by Garethmoffatt
Fri Jul 06, 2018 3:00 pm
Forum: Graphics programming
Topic: [solved] Ensuring gtk_application is unique
Replies: 1
Views: 1144

[solved] Ensuring gtk_application is unique

I am using GTK3+ (in c). I want to ensure I don't have multiple instances of the application running. (conflicts over resources) Googling suggests that using a GtkApplication with unique application ID ensures this... but my practical experience is that it doesn't! Any pointers to how to detect is a...
by Garethmoffatt
Tue Jun 26, 2018 5:52 pm
Forum: Graphics programming
Topic: Gtk3 exiting through delete_event handler (SOLVED)
Replies: 8
Views: 2034

Re: Gtk3 exiting through delete_event handler

Paeryn, Thanks gtk_window_close(...) Does exactly what I want to do by calling the delete_event handler for me. I'm pretty much self taught so was looking to Google to provide the answers and was drawing a blank. I knew I wanted to go out through the delete_event handler so that the window X and any...
by Garethmoffatt
Tue Jun 26, 2018 11:10 am
Forum: Graphics programming
Topic: Gtk3 exiting through delete_event handler (SOLVED)
Replies: 8
Views: 2034

Re: Gtk3 exiting through delete_event handler

The reason for the “ are you sure?” Message in the delete handler is because I want to ask the question and save files etc independent of why the program exits. I can move the msg box etc in to a function that gets called from delete, but I’m not sure if that solves your concern. Up till I wanted to...
by Garethmoffatt
Tue Jun 26, 2018 3:50 am
Forum: Graphics programming
Topic: Gtk3 exiting through delete_event handler (SOLVED)
Replies: 8
Views: 2034

Re: Gtk3 exiting through delete_event handler

Sorry it has taken a while to post code. Here is a cut down example that responds almost like the main program I am working on. #include <gtk/gtk.h> #include <glib.h> #include <glib/gstdio.h> #include <termios.h> #include <fcntl.h> #include <time.h> #include <stdlib.h> #include <string.h> #include <...
by Garethmoffatt
Sat Jun 23, 2018 3:43 pm
Forum: Graphics programming
Topic: Gtk3 exiting through delete_event handler (SOLVED)
Replies: 8
Views: 2034

Gtk3 exiting through delete_event handler (SOLVED)

I have a gtk3 application that i have written that includes a delete_event handler. When I click the window X, it handles a "do you want to quit?" message box and saves data if it has changed etc. There are other places in my code where I also want to have the program terminate, but elegently throug...
by Garethmoffatt
Fri Mar 30, 2018 11:15 pm
Forum: Troubleshooting
Topic: Terminal doesn't open properly first time
Replies: 2
Views: 427

Re: Terminal doesn't open properly first time

Would you believe it has only done it twice since your post?

At least I have pinned it down to .bashrc. I’ve added 10 way points in that and now just need it to fail again!

Thanks for the pointer, I was going nowhere!

Best regards

Gareth
by Garethmoffatt
Mon Mar 12, 2018 1:13 am
Forum: Troubleshooting
Topic: Terminal doesn't open properly first time
Replies: 2
Views: 427

Terminal doesn't open properly first time

When I click on the terminal icon in Pixel, the first time since boot, sometimes the terminal window doesn't open properly. I get the standard license and no warranty message and the last login time message, but it doesn't give the path prompt and typing commands has no effect. The second terminal w...
by Garethmoffatt
Fri Dec 01, 2017 10:41 pm
Forum: Beginners
Topic: Uptime gives idle > 4 times running time
Replies: 2
Views: 443

Re: Uptime gives idle > 4 times running time

If anybody follows this, the total processing time is calculated by adding the first 7 numbers after the CPU number.

Idle time is 4 and 5. So the % load is 4+5 / sum 1 to 7 * 100

The units of the /proc/stat calculations are 1/100’s of a second.

Thanks. Gareth
by Garethmoffatt
Sat Nov 25, 2017 2:26 pm
Forum: Beginners
Topic: Uptime gives idle > 4 times running time
Replies: 2
Views: 443

Uptime gives idle > 4 times running time

I want to measure how idle my Pi is. I'm using up time and taking the uptime and idle time 15 seconds apart. When I calculate the idle time, I am getting ~ 75 seconds. I've read elsewhere that the idle time is the total for all processors so I have been dividing by 4. but this is still giving me an ...
by Garethmoffatt
Sat Jul 01, 2017 11:48 am
Forum: Graphics programming
Topic: gtk_combo_box_text_remove_all causes segmentation fault
Replies: 1
Views: 3277

gtk_combo_box_text_remove_all causes segmentation fault

I'm experimenting with GTK-3 text combo boxes. I am reading data from a text file and creating a g_slist to store it. To select an item, I'm filling a text combo box. When the user selects an item, I compare the selection with each element in the list to find the related data. That all works fine. I...
by Garethmoffatt
Sat Jun 24, 2017 12:05 pm
Forum: Troubleshooting
Topic: cups - :631 cant be reached
Replies: 10
Views: 5015

Re: cups - :631 cant be reached

Thanks Dougie, That works fine and I managed to go in and add my printer. There is not the correct Brother printer driver and the brother website only provides i386 drivers... I'm obviously going to have to work hard for this or see if one of the provided drivers works by trial and error! Thanks for...
by Garethmoffatt
Sat Jun 24, 2017 1:20 am
Forum: Troubleshooting
Topic: cups - :631 cant be reached
Replies: 10
Views: 5015

Re: cups - :631 cant be reached

Dougie, This is what I got.... no idea what it means Last login: Thu Jun 22 22:19:00 2017 from 192.168.0.18 [email protected]:~ $ sudo systemctl status cups [sudo] password for gareth: ● cups.service - CUPS Printing Service Loaded: loaded (/lib/systemd/system/cups.service; enabled) Active: failed (Result:...
by Garethmoffatt
Fri Jun 23, 2017 12:05 pm
Forum: Troubleshooting
Topic: cups - :631 cant be reached
Replies: 10
Views: 5015

Re: cups - :631 cant be reached

Dougie, I ran apt-get update and apt-get upgrade as that seams to be a common suggestion as a first step to fix things. Then apt-get install cups. The shell reported that cups was already the latest version. It is still not running using the netstat test. Anything I can do to try and make it run? Th...
by Garethmoffatt
Fri Jun 23, 2017 2:35 am
Forum: Troubleshooting
Topic: cups - :631 cant be reached
Replies: 10
Views: 5015

Re: cups - :631 cant be reached

Sudo netstat -tinp | grep cups
Gives nothing.

I assume that is bad?

Gareth
by Garethmoffatt
Thu Jun 22, 2017 1:24 am
Forum: Troubleshooting
Topic: cups - :631 cant be reached
Replies: 10
Views: 5015

cups - :631 cant be reached

I am trying to install a printer for my pi. I followed to howtogeek instructions for downloading cups and setting up printers. The install seamed to have worked, & I added myself to the printer group. However trying to access the admin page via the web browser from my pi http://mypi:631 results in t...
by Garethmoffatt
Thu Jun 22, 2017 12:54 am
Forum: Official Foundation Display
Topic: Turning off backlight with echo 1 > /sys/...
Replies: 2
Views: 1573

Turning off backlight with echo 1 > /sys/...

I have an official 7" display that I use sometimes and use HDMI usually. For a while I was using ignore_lcd=1 in /boot/config.txt so I could use my HDMI monitor, but the lcd screen flashed and faded black and white in a disturbing manor. I tried to use the echo 1 > /sys/... code that I found on this...
by Garethmoffatt
Sun Jun 11, 2017 5:18 pm
Forum: Graphics programming
Topic: Correct way to use g_io_add_watch
Replies: 3
Views: 2713

Re: Correct way to use g_io_add_watch

Hah!
You fixed this on my last post, I was just coming back to close this one out as fixed!
Thanks for the help.
Next I'm off in search of a segmentation fault... I
Regards
Gareth
by Garethmoffatt
Sun Jun 11, 2017 5:07 pm
Forum: Graphics programming
Topic: Correct way to use g_io_add_watch
Replies: 3
Views: 2713

Correct way to use g_io_add_watch

I am trying to get data from an asynchronous serial port connection. In gtk-2.0, I discovered that I could do what I wanted by trial and error using the following code: serialName = strdup("/dev/ttyACM0"); g_print("serialOpen returns %d\n",fd = serialOpen(serialName,57600)); free(serialName); // add...
by Garethmoffatt
Sun Jun 11, 2017 4:40 pm
Forum: Graphics programming
Topic: Gtk-Message: GtkDialog mapped without a transient parent.
Replies: 6
Views: 2863

Re: Gtk-Message: GtkDialog mapped without a transient parent

Peter, This is not quite a minimum example, but one I made for a different reason. #include <gtk/gtk.h> #include <termios.h> #include <fcntl.h> #include <string.h> #include <stdio.h> #include <stdlib.h> #define true TRUE #define false FALSE /* widget test that displays data from car sensor test proj...

Go to advanced search