Go to advanced search

by swampdog
Sun Mar 10, 2019 10:46 pm
Forum: C/C++
Topic: C programming project work
Replies: 2
Views: 688

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: 1285

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: 1285

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: 1907

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: 26960

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: 2364

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: 2364

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: 2364

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: 8315

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: 2905

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: Raspberry Pi OS
Topic: Problem Disk with ext4 (was NTFS)
Replies: 5
Views: 1397

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: 15486

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: 9423

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: 1787

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: 1787

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: 1741

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.
by swampdog
Sat Oct 15, 2016 1:11 am
Forum: C/C++
Topic: The MagPi does C :-)
Replies: 124
Views: 27070

Re: The MagPi does C :-)

Can a discussion of the history of C go in another thread please ? Let's leave this one clear to discuss the content of any future tutorials or books. PeterO Agreed. Back to the plot. The most obvious complex C item, is strings. Every man & his dog has written "a brilliant string library". The conc...
by swampdog
Sat Oct 15, 2016 12:57 am
Forum: C/C++
Topic: Cross-Compile missing ld-linux-armhf.so.3
Replies: 2
Views: 8469

Re: Cross-Compile missing ld-linux-armhf.so.3

No. Both natively and within my cross (under centos 6) "ld-linux-armhf.so.3" points to some variant of "ld-2.*.*.so". Native.. $ lc -d /lib/arm-linux-gnueabihf/ld* -rwxr-xr-x 1 root root 134448 Apr 2 2016 /lib/arm-linux-gnueabihf/ld-2.19.so lrwxrwxrwx 1 root root 10 Apr 2 2016 /lib/arm-linux-gnueabi...
by swampdog
Fri Oct 14, 2016 10:49 am
Forum: C/C++
Topic: The MagPi does C :-)
Replies: 124
Views: 27070

Re: The MagPi does C :-)

Back in K&R I'd have happily written "void main(..)" K&R C does not include void. That came afterwards and is included in the ANSI standard. In the years following the publication of K&R C, several features were added to the language, supported by compilers from AT&T (in particular PCC[15]) and som...
by swampdog
Fri Oct 14, 2016 7:06 am
Forum: C/C++
Topic: Learning C++ for the first time. Feedback?
Replies: 6
Views: 1741

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

Here's some ideas on how to get more work out of less code. It's far from perfect btw. Just hints.. #ifndef TC #define TC class TestClass { private: int value; public: TestClass (); TestClass (int x); TestClass (const TestClass&); TestClass & operator=(const TestClass&); TestClass & operator*=(const...
by swampdog
Fri Oct 14, 2016 5:32 am
Forum: C/C++
Topic: The MagPi does C :-)
Replies: 124
Views: 27070

Re: The MagPi does C :-)

Thanks @jojopi, I was beginning to think I was the voice in the wilderness . Well, it's swings & roundabouts. Back in K&R I'd have happily written "void main(..)" because it meant you didn't care about the return value. Obviously "int main(..) {/*code*/;return 0;}" is the most portable way to proce...
by swampdog
Wed Oct 12, 2016 10:22 pm
Forum: C/C++
Topic: C++ program executed from PHP not exporting GPIO properly
Replies: 4
Views: 1340

Re: C++ program executed from PHP not exporting GPIO properl

I don't know php but replace your code with a bit of shell script which executes your code. That will allow you to edit the shell script to see what is going on.

#!/bin/bash
touch /tmp/z
echo $PATH
[etc]
by swampdog
Wed Oct 12, 2016 10:05 pm
Forum: C/C++
Topic: Put a variable in system () call? Or better way?
Replies: 6
Views: 1199

Re: Put a variable in system () call? Or better way?

Just a note of warning. If you intend to have it respond to commands from the outside world you'll need some security in order to prevent it responding to anything but you. ;-)
by swampdog
Wed Oct 12, 2016 9:56 pm
Forum: Beginners
Topic: Port Forward on Pi acting as Wireless to Wired Bridge
Replies: 5
Views: 2596

Re: Port Forward on Pi acting as Wireless to Wired Bridge

If by "WWAN" you mean something which tells you about the Verizon Hotspot then then you'll have to ask someone who has experienced that system. Unfortunately from my point of view there's one of two possibilities: a) wlan0 is changing to 70.x.x.x b) wlan0 is staying as 192.168.1.98 and this verizon ...
by swampdog
Wed Oct 12, 2016 9:52 pm
Forum: Advanced users
Topic: cross compilation "__fixsfdi"
Replies: 7
Views: 1695

Re: cross compilation "__fixsfdi"

Nope. I never tried to. I did just try with gcc 6.2 and same result. I'm sure someone else posted some detail on it but my memory is terrible so no link. :-(

Go to advanced search