Go to advanced search

by swampdog
Sat Mar 16, 2019 12:22 am
Forum: C/C++
Topic: How to assign a variable value from a text file
Replies: 6
Views: 1932

Re: How to assign a variable value from a text file

We need an example. In lieu of that.. admin@pi05:~ $ apropos strto strtod (3) - convert ASCII string to floating-point number strtof (3) - convert ASCII string to floating-point number strtoimax (3) - convert string to integer strtok (3) - extract tokens from strings strtok_r (3) - extract tokens fr...
by swampdog
Thu Mar 14, 2019 11:56 pm
Forum: Raspbian
Topic: Webmin or an alternative
Replies: 10
Views: 1478

Re: Webmin or an alternative

Looks like I failed to make a note of the procedure Ah. Looks like it's still in the history of my "printer" rpi.. $ sudo dpkg -i webmin_1.831_all.deb $ sudo systemctl status webmin $ wget wget http://www.webmin.com/jcameron-key.asc $ sudo apt-key add jcameron-key.asc $sudo apt-get update $sudo apt...
by swampdog
Thu Mar 14, 2019 11:41 pm
Forum: Raspbian
Topic: Webmin or an alternative
Replies: 10
Views: 1478

Re: Webmin or an alternative

I've got "sarge" webmin running under jessie just fine and it will update. admin@pi07:~ $ cat /etc/apt/sources.list | grep webm deb http://download.webmin.com/download/repository sarge contrib Looks like I failed to make a note of the procedure but if you google how to install it for debian you'll l...
by swampdog
Thu Mar 14, 2019 2:32 am
Forum: Advanced users
Topic: What is the latest MySQL on Pi?
Replies: 7
Views: 621

Re: What is the latest MySQL on Pi?

This idea may not be suitable for your needs: you could install a virtual machine on your PC with an older version of mysql workbench running in it.
by swampdog
Wed Mar 13, 2019 9:12 pm
Forum: C/C++
Topic: New to Raspberry, old to programming
Replies: 40
Views: 5650

Re: New to Raspberry, old to programming

It would be more trouble than it's worth trying to do anything from WinXP with it being out of support. Like the others have suggested, you can develop quite easily on the rpi directly. You can certainly use your XP machine for the display etc (hint: VNC/putty) ... though before you dive into that i...
by swampdog
Tue Mar 12, 2019 9:08 pm
Forum: Troubleshooting
Topic: Mount ssd usb as pi, not as root.
Replies: 2
Views: 106

Re: Mount ssd usb as pi, not as root.

Are you sure you want to do it that way round? If the disk isn't being shared elsewhere then I'd just mount it as root then "chown" it. /dev/sda1 /media/raspi ext4 defaults 0 0 $ sudo su - # mount /media/raspi # cd /media # chown -Rv pi:pi raspi/ #^D $ ls -l /media/ ..now user pi can access it.
by swampdog
Mon Mar 11, 2019 10:32 pm
Forum: C/C++
Topic: C/C++ Memory Usage Code
Replies: 25
Views: 4079

Re: C/C++ Memory Usage Code

Would like to see other methods and compare. I have a feeling that the one I posted is not that efficient. Well, as I had some unexpected free time today I thought I'd try the bloaty approach. This is because I watched a youtube vid last night about old games - Dungeon Keeper & Theme Hospital so I'...
by swampdog
Mon Mar 11, 2019 4:04 am
Forum: C/C++
Topic: How to get CPU load in C
Replies: 15
Views: 2184

Re: How to get CPU load in C

Out of curiosity I went hunting for the 'top' source code. Oh what a merry trail that led me on! Suffice it to say "man 5 proc" is the easiest way to get the information although if you guys really want to get go to town "apt-cache search libprocps" and install the corresponding dev library then (sa...
by swampdog
Mon Mar 11, 2019 2:32 am
Forum: Raspbian
Topic: [BASH-SCRIPT] Building a headless Raspberry Pi
Replies: 2
Views: 297

Re: [BASH-SCRIPT] Building a headless Raspberry Pi

You might want to check 'dialog' exists early on or the user is going to get a blank screen (hint: 'which dialog'). I'd also refrain from being root except when you have to (ie: I'd use 'sudo' in the script for 'dd/mount' etc) as the user has to be able to 'sudo' in the first place. You can also mak...
by swampdog
Sun Mar 10, 2019 10:46 pm
Forum: C/C++
Topic: C programming project work
Replies: 2
Views: 538

Re: C programming project work

You might find this useful. It's about the clearest intro to threading in C I've seen.. https://www.youtube.com/watch?v=nVESQQg-Oiw https://www.youtube.com/watch?v=nlHIuG3RQ0g ^^^the vids have links to github where you can grab the sources. For in-depth info on the functions.. $ apropos pthread $ ma...
by swampdog
Fri Mar 01, 2019 7:20 pm
Forum: Troubleshooting
Topic: Terribly slow networking
Replies: 12
Views: 703

Re: Terribly slow networking

"datalink type: EN10MB (Ethernet)" Is it possible my Pi's ethernet is running at 10 Mbps instead of 100? What made it do that. sudo ethtool eth0 | grep "Speed:" You could try two terminals on your pi and 'netcat' "localhost". It might (or might not) help narrow the problem down. Typical output.. fo...
by swampdog
Thu Feb 28, 2019 11:45 pm
Forum: Troubleshooting
Topic: Terribly slow networking
Replies: 12
Views: 703

Re: Terribly slow networking

Try this. It keeps the disks out the picture..

Code: Select all

receiver$ netcat -l 1234 >/dev/null
sender$ dd if=/dev/zero bs=1M count=256 | pv | netcat -q 0 receiver 1234
..should get >10MiB/s else..

pi3b$ sudo arp-scan -I eth0 -l
..(or wlan0) and look for ip address collisions.
by swampdog
Tue Feb 26, 2019 8:08 pm
Forum: C/C++
Topic: WatchDog
Replies: 5
Views: 1410

Re: WatchDog

I've not used /dev/watchdog but a quick google about it and the fact the rpi3 next to me has 'watchdogd' running then test it works.. $sudo su - #echo "anything" >/dev/watchdog ^^^reboots after a few seconds. https://github.com/torvalds/linux/blob/master/Documentation/watchdog/watchdog-api.txt It ap...
by swampdog
Sat Feb 23, 2019 1:45 am
Forum: C/C++
Topic: Debugging on a Pi
Replies: 18
Views: 22946

Re: Debugging on a Pi

In case nobody knows you can turn on core dumps which can be a much faster way to get to the problem. $ cat c.cc #include <iostream> using namespace std; void foo () { char *p=0; *p=-99; } main() { foo(); return 0; } $ ulimit -a $ ulimit -c unlimited $ gcc -o c -g c.cc $ ./c Segmentation fault (core...
by swampdog
Sat Feb 23, 2019 12:15 am
Forum: C/C++
Topic: [C] compatibility data types 32-64 bit?
Replies: 18
Views: 1492

Re: [C] compatibility data types 32-64 bit?

Heater, Which leaves me wondering how we could come to different conclusions about the safety of C/C++ and pitfalls of cross-platform code. We diverged because we forgot my (3) point. I'm not talking directly to (3) hardware whereas you are in which case I'd likely be be doing the same as yourself b...
by swampdog
Thu Feb 14, 2019 2:49 pm
Forum: C/C++
Topic: [C] compatibility data types 32-64 bit?
Replies: 18
Views: 1492

Re: [C] compatibility data types 32-64 bit?

Spend some time porting big projects from one hardware, OS, compiler to another or creating cross platform software and you soon become painfully aware of all this. You assume too much sir! Ibm Aix 5 upward. Redhat 4 upward. Sles 9 upward. You'll be aware all the above in earlier versions came in 3...
by swampdog
Wed Feb 13, 2019 8:25 pm
Forum: C/C++
Topic: [C] compatibility data types 32-64 bit?
Replies: 18
Views: 1492

Re: [C] compatibility data types 32-64 bit?

As I'm here I'll stick my oar in and say not to worry about it unless it becomes a problem. Three areas.. (1) Overflow in the sense you need a larger number range. (2) Storage in that you've run out. (3) Hardware, talking to it. ..and it's only (3) where you must know. (1) and (2) causing problems i...
by swampdog
Wed Feb 13, 2019 6:43 pm
Forum: C/C++
Topic: GCC 6 Cross Compiler
Replies: 16
Views: 5604

Re: GCC 6 Cross Compiler

I can't help much except to say I built gcc-6.3.0 some time ago using the following crosstools-ng (1.23.0) ".config".. CT_CONFIGURE_has_static_link=y CT_CONFIGURE_has_wget=y CT_CONFIGURE_has_curl=y CT_CONFIGURE_has_stat_flavor_GNU=y CT_CONFIGURE_has_libtool_2_4_or_newer=y CT_CONFIGURE_has_libtoolize...
by swampdog
Thu Jan 24, 2019 5:26 am
Forum: Other programming languages
Topic: Raspberry Pi MySQL Remote Connection (error: 10061)
Replies: 5
Views: 1758

Re: Raspberry Pi MySQL Remote Connection (error: 10061)

cat<<EOF > z CREATE USER '${A_USER}'@'localhost' IDENTIFIED BY '${A_PASS}'; CREATE USER '${A_USER}'@'' IDENTIFIED BY '${A_PASS}'; GRANT ALL PRIVILEGES ON *.* TO '${A_USER}'@'localhost' WITH GRANT OPTION; GRANT ALL PRIVILEGES ON *.* TO '${A_USER}'@'' WITH GRANT OPTION; FLUSH PRIVILEGES; EOF mysql -u ...
by swampdog
Mon Jan 14, 2019 6:24 pm
Forum: Raspbian
Topic: Problem Disk with ext4 (was NTFS)
Replies: 5
Views: 904

Re: Problem Disk with ext4 (was NTFS)

Just on the offchance..

I plugged a cheap usb sata caddy into an rpi3 over xmas and noticed it will power down and vanish off the usb unless it's mounted reasonably quick - couple of minutes. "lsusb" / "lsscsi" for that and "tail -f /var/log/messages".
by swampdog
Mon Jan 14, 2019 5:21 pm
Forum: General programming discussion
Topic: TUTORIAL: File Sorting on the Raspberry Pi
Replies: 41
Views: 12386

Re: TUTORIAL: File Sorting on the Raspberry Pi

That's a rather dangerous operation, more so if you were to put it in a script. Why not use symlinks instead? #!/bin/bash NAM=`basename "$0"` empty=$(ls -A) [ -z "$empty" ] || { echo "$NAM: Nope. This folder isn't empty!" 1>&2 exit 1 } [ -z "$1" ] && { echo "$NAM: Usage: $NAM [ source folder ]" 1>&2...
by swampdog
Mon Jan 14, 2019 3:55 pm
Forum: C/C++
Topic: C++ IDE
Replies: 40
Views: 7771

Re: C++ IDE

How can qtcreator be installed on the Pi? $ sudo apt-get install qtcreator I'm not sure how much mileage you'll get out of it without an rpi3 though! One thing I did notice when I just installed it here was it didn't auto detect a compiler so.. Tools->Options->[Compilers]->Add->[GCC] Compiler Path=...
by swampdog
Fri Dec 21, 2018 4:51 pm
Forum: C/C++
Topic: accessing global 2-dim arrays from an object
Replies: 10
Views: 1517

Re: accessing global 2-dim arrays from an object

If memory is that short then get the max space immediately. That way you don't have to worry about it running out plus you'll need less code. $ g++ -o c -Os c.cc && strip c && ./c Checking omitted for brevity.. #include <cstdlib> #include <cstring> #include <cstdio> #define MENULEN 6 #define LINELEN...
by swampdog
Thu Dec 20, 2018 7:11 pm
Forum: C/C++
Topic: accessing global 2-dim arrays from an object
Replies: 10
Views: 1517

Re: accessing global 2-dim arrays from an object

$gcc -v 2>&1 | grep ^gcc gcc version 4.9.2 (Raspbian 4.9.2-10+deb8u1) $ g++ -o c -std=c++0x c.cc $ cat c.cc #include <iostream> #include <ostream> #include <iterator> #include <string> #include <cstring> #include <deque> #include <vector> //#define DLIST typedef std::string Str; #if defined(DLIST) t...
by swampdog
Sat Oct 15, 2016 2:03 am
Forum: C/C++
Topic: Learning C++ for the first time. Feedback?
Replies: 6
Views: 1405

Re: Learning C++ for the first time. Feedback?

I've a decade old "twiddly" co-ordinate class that serves no purpose other than being an exercise. It's a template'd thing.

Go to advanced search