Go to advanced search

by jahboater
Wed May 12, 2021 4:27 pm
Forum: Python
Topic: Interpreter ?
Replies: 14
Views: 364

Re: Interpreter ?

Well it's for an electronic product. What's the point in giving it away? But you are happy to use all the open source stuff written by others? Since we are discussing Python, I guess, to avoid hypocrisy, you would not use the Python interpreter and instead write your own? Most of the software that ...
by jahboater
Wed May 12, 2021 4:20 pm
Forum: SDK
Topic: [SOLVED] Possible to replace printf and or putchar
Replies: 9
Views: 174

Re: Possible to replace printf and or putchar

See man sprintf

sprintf() writes to a string.
dprintf() writes to a file descriptor
fprintf() writes to a stream (FILE*) (like stdout, but your choice).

There is also putc() etc for single characters.
by jahboater
Wed May 12, 2021 7:16 am
Forum: Python
Topic: Interpreter ?
Replies: 14
Views: 364

Re: Interpreter ?

but I kinda wish I would have attempted C because of the aspect of more source code protection. (Although I guess C can probably be reverse engineered also). Why do you want that ? Its true that (heavily optimized) C binaries are harder to reverse engineer, but its the last thing I think about when...
by jahboater
Tue May 11, 2021 6:15 pm
Forum: C/C++
Topic: gcc_compile script - configure options for PiB or Pi3A ?
Replies: 26
Views: 896

Re: gcc_compile script - configure options for PiB or Pi3A ?

Next challenge: Pico! Purely for fun, I tried the build entirely in memory on an 8GB 2.1GHz Pi4 - hoping for a record! Download / untar / build the entire thing in a 7GB tmpfs disk. This should, in theory, be very very fast. But it took 3 hour 46minutes :( GCC 11.1 (LANG=c,c++). I used make -j4 as n...
by jahboater
Tue May 11, 2021 3:39 pm
Forum: SDK
Topic: How to convert a double to a C string?
Replies: 16
Views: 396

Re: How to convert a double to a C string?

snprintf(bfr, 50, "%.2f", x);

or

sprintf(bfr, "%.2f", x);

which wont check that the buffer is large enough (but the C compiler may do so instead).

On the Pi you can say "man sprintf" to display the documentation.
by jahboater
Tue May 11, 2021 3:20 pm
Forum: Python
Topic: Interpreter ?
Replies: 14
Views: 364

Re: Interpreter ?

People usually program computers in a simple "english like" language that is good for humans to read and write. Such a language is Python, other common ones are C, C++, Fortran, Bash, Rust and many many others. The computer does not understand english. It understands a series of binary num...
by jahboater
Tue May 11, 2021 2:53 pm
Forum: C/C++
Topic: Is C++ / Pigpio a reasonable choice for device control?
Replies: 3
Views: 135

Re: Is C++ / Pigpio a reasonable choice for device control?

Is c++ and pigpio a good choice in terms of being actively supported? I am not asking about help-with-development type support, but rather the tools being kept up to date with hardware and O/S changes and being relatively reliable. C/C++ are not going anywhere. C especially is incredibly stable, te...
by jahboater
Tue May 11, 2021 2:30 pm
Forum: Advanced users
Topic: Pi4 Overclocking question
Replies: 21
Views: 1075

Re: Pi4 Overclocking question

I've remember a review that this heat sink does not come in contact with the USB3 chip and due to the restricted airflow can cause that chip to overheat. Can you verify whether the USB3 chip is cooled and if not whether there is a solution for this. The application would be a heavily loaded file se...
by jahboater
Tue May 11, 2021 9:46 am
Forum: General discussion
Topic: MOST RELIABLE SD CARD !!!!
Replies: 6
Views: 326

Re: MOST RELIABLE SD CARD !!!!

+1

I have Sandisk A1 class cards in all my Pi's for years and simply never see failures or corruption.
They are fast enough that I don't feel an urgent need to use an SSD (and 8GB Pi4's have plenty of space for a huge disk cache).
by jahboater
Tue May 11, 2021 9:23 am
Forum: C/C++
Topic: gcc_compile script - configure options for PiB or Pi3A ?
Replies: 26
Views: 896

Re: gcc_compile script - configure options for PiB or Pi3A ?

Ah the luxury of a Pi4 ... I am just adding support for the "go" language. LANG=c,d,c++,go,fortran using make -j 5 and no swap at all. Should complete in 3 hours or so at 2.1GHz. Also /tmp is in memory (4GB tmpfs disk) which might speed up compiler temporary files. $ free -h total used fre...
by jahboater
Tue May 11, 2021 7:12 am
Forum: Other programming languages
Topic: How Slow is Go?
Replies: 10
Views: 387

Re: How Slow is Go?

My understanding is the Go compiler quickly produces slower executables than either GCC or LLVM because it's based on the Plan 9 toolchain. The idea in this thread is to compare the relative slowness of Go on the Pi compared to the relative slowness of Go on other architectures. To do this, near-id...
by jahboater
Sun May 09, 2021 6:37 pm
Forum: C/C++
Topic: For beginners
Replies: 18
Views: 569

Re: For beginners

Heater wrote:
Sun May 09, 2021 6:20 pm
Julia takes a bit of effort to get installed and working on the Pi
The latest release 1.6.1 that came out a few days ago, now has ready to go binaries for the 32-bit Pi if you want to try it.
ARMv7 hard-float - perhaps they provided it specially for the Pi!!
Aarch64 has always been available.
by jahboater
Sun May 09, 2021 6:34 pm
Forum: C/C++
Topic: For beginners
Replies: 18
Views: 569

Re: For beginners

structuring one's C++ code is no issue if you learn C++ by Arduino tutorials. That's because you are not really learning C++ by using the Arduino tools. I have to disagree, by Arduino tutorials I learned programming mobile robots with multiple sensors, a autonomous chess engine, and also neural bac...
by jahboater
Sun May 09, 2021 9:53 am
Forum: C/C++
Topic: For beginners
Replies: 18
Views: 569

Re: For beginners

swampdog wrote:
Sun May 09, 2021 9:46 am
This is why C++ is hard and not for the novice. Imagine all the things they have to already know to figure out that 0 typo should be "0" and not '0'. ;-)
Yes indeed, that's awful.

Perhaps start with C where strings are very simple and the error messages are much easier to understand.
by jahboater
Sun May 09, 2021 9:41 am
Forum: C/C++
Topic: For beginners
Replies: 18
Views: 569

Re: For beginners

Guys, i think about start learning C++. It really interest me but i don't know anything about programming. I believe the most popular teaching language these days is Python. Python is included with Raspberry Pi OS, installed and ready to use, so its easy to get started. There is also vast amount of...
by jahboater
Sun May 09, 2021 8:57 am
Forum: C/C++
Topic: GCC 11.1
Replies: 11
Views: 574

Re: GCC 11.1

I didn't have a chance to look at this until now. The gcc build "contrib/download_prerequisites" conflicts with top level 'configure'. The former is saying mpfr='mpfr-3.1.4.tar.bz2' whereas the latter has "#if MPFR_VERSION < MPFR_VERSION_NUM(3,1,6)". Are you saying they have mov...
by jahboater
Sun May 09, 2021 12:00 am
Forum: Off topic discussion
Topic: Share Your BASH Aliases
Replies: 18
Views: 504

Re: Share Your BASH Aliases

Here are a few: alias p=python3 alias nmap='sudo nmap -sn 192.168.0.0/24' alias m=make alias v=valgrind alias free='free -h' alias d='diff -spd' alias pi='ssh pi@pi' alias pi32='ssh pi@pi32' alias lz='lzip -k -m272 -s256MiB' alias td=timedatectl alias t=touch alias getlite='wget --trust-server-names...
by jahboater
Sat May 08, 2021 11:47 pm
Forum: C/C++
Topic: [solved]Reading command inputted
Replies: 103
Views: 1641

Re: [solved]Reading command inputted

ejolson wrote:
Sat May 08, 2021 10:30 pm
Make a file with a space in the filename and then try to cat it.
Ha! Yes, your right, it needs the double quotes to make that work.

exec "$@"

Code: Select all

$ echo hello >'abc def'
$
$ ./try.sh cat 'abc def'
hello
$
by jahboater
Sat May 08, 2021 10:26 pm
Forum: C/C++
Topic: [solved]Reading command inputted
Replies: 103
Views: 1641

Re: [solved]Reading command inputted

Did you test the version without quotes with arguments that have spaces? Yes: $ cat try.sh exec $@ $ $ ./try.sh echo hello world hello world $ ./try.sh ls -x /boot COPYING.linux LICENCE.broadcom bcm2708-rpi-b-plus.dtb bcm2708-rpi-b-rev1.dtb bcm2708-rpi-b.dtb bcm2708-rpi-cm.dtb bcm2708-rpi-zero-w.dt...
by jahboater
Sat May 08, 2021 6:42 pm
Forum: C/C++
Topic: [solved]Reading command inputted
Replies: 103
Views: 1641

Re: [solved]Reading command inputted

just to make sure I deleted the ./a.out and compiled again, same results ‽‽‽‽‽‽‽‽ why is this happening Something must change to get a different result. Different test, different compiler, different optimization level, different OS ....... It fails with a seg fault on my Pi: $ ./try `ls -l /etc` Se...
by jahboater
Sat May 08, 2021 4:52 pm
Forum: C/C++
Topic: [solved]Reading command inputted
Replies: 103
Views: 1641

Re: [solved]Reading command inputted

ejolson wrote:
Sat May 08, 2021 4:48 pm
I meant in C. Do you need quotes for the shell version to work properly?
No it seems to work fine without.
It also works without the "exec" of course, but that must be slower (though it does give the shortest possible solution :) )
by jahboater
Sat May 08, 2021 4:46 pm
Forum: C/C++
Topic: [solved]Reading command inputted
Replies: 103
Views: 1641

Re: [solved]Reading command inputted

The current code takes the arguments in argv, concatenates them into a string, then passes that string to a command interpreter which parses the arguments back out based on white space to create a new array of arguments which are passed to an exec call for the program. Why not just use a proper exe...
by jahboater
Sat May 08, 2021 3:59 pm
Forum: Off topic discussion
Topic: Share Your BASH Aliases
Replies: 18
Views: 504

Re: Share Your BASH Aliases

Note that the "ls" ones are already in ~/.bashrc, you just have to uncomment them.

alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'
by jahboater
Sat May 08, 2021 3:48 pm
Forum: C/C++
Topic: [solved]Reading command inputted
Replies: 103
Views: 1641

Re: [solved]Reading command inputted

Changing the 8096 to something like 5 then running ./a.out echo "2131323" still would give the expected outcome, as if I just open a terminal and did it, the size doesn't seem to matter! You have only overflowed the buffer by 3 bytes! Likely spare space is around to allow alignment of the...
by jahboater
Sat May 08, 2021 3:38 pm
Forum: C/C++
Topic: [solved]Reading command inputted
Replies: 103
Views: 1641

Re: [solved]Reading command inputted

3) You don't need to worry about the buffer overflow issue if you follow the advice I gave in my previous post, which is to write a specifications document for the program. Every program needs to have a specifications document. There are sometimes performance reasons why you might document "if...

Go to advanced search