Go to advanced search

by 1dot0
Sat Oct 28, 2017 10:31 am
Forum: C/C++
Topic: Problem with Geany - 'execute' command displays blank terminal window
Replies: 8
Views: 4007

Re: Problem with Geany - 'execute' command displays blank terminal window

I think you will find the solution here: https://www.raspberrypi.org/forums/viewtopic.php?f=66&t=191818#p1203549 buja, the link you posted is about Python. @andrum99: try what Paeryn implied, perhaps something simple like printf("here I am"); int c=getchar(); or perhaps fprintf(stderr, "here I am")...
by 1dot0
Wed Oct 18, 2017 8:45 am
Forum: C/C++
Topic: What is the best api to play audio files?
Replies: 2
Views: 930

Re: What is the best api to play audio files?

the most convenient one was once posted here somewhere else, it goes like

Code: Select all

#include <cstdlib>
using namespace std;


void PlaySound(std::string filename){
   system( ("aplay " + filename).c_str() );
}

// ...
PlaySound("m1.wav");
by 1dot0
Fri Oct 13, 2017 5:12 pm
Forum: C/C++
Topic: WiringPi Serial help
Replies: 8
Views: 2116

Re: WiringPi Serial help

1dot0, it worked!!! Thank you thank you thank you...! Sending all the good vibes and good karma your way. Much appreciated. Blessings! glad to hear that it worked! I know that the first steps are the hardest... ;) After all, you may wish to learn C for Linux by a tutorial like his one: http://fract...
by 1dot0
Fri Oct 13, 2017 4:39 pm
Forum: C/C++
Topic: WiringPi Serial help
Replies: 8
Views: 2116

Re: WiringPi Serial help

can you see your key strokes in the terminal console?
If yes, then your keyboard is just writing to stdin, not Serial.

In that case you perhaps better use stdio.h commands, like getchar()
http://www.cplusplus.com/reference/cstdio/getchar/
by 1dot0
Fri Oct 13, 2017 3:24 pm
Forum: C/C++
Topic: WiringPi Serial help
Replies: 8
Views: 2116

Re: WiringPi Serial help

hi, first perhaps a minor issue: char on Linux and 32bit ARM processors is an unsigned char, so it can never be -1. second, how do you have connected your keyboard and the serial terminal? at ttyAMA0 ? On the Pi 2 it's the UART port on the GPIO header, on the Pi3 it's the internal port used by BT. T...
by 1dot0
Sun Oct 01, 2017 2:09 pm
Forum: C/C++
Topic: Closing serial port when doing ^C
Replies: 4
Views: 2177

Re: Closing serial port when doing ^C

In my example pattern I only pass -3 to exit () because I usually have different arbitrary exit conditions in my own programs, each one passes a proprietary number, so I can see after exitting, why the program had terminated eventually.
by 1dot0
Fri Sep 29, 2017 8:15 am
Forum: C/C++
Topic: Closing serial port when doing ^C
Replies: 4
Views: 2177

Re: Closing serial port when doing ^C

in short words, I'm doing it this way: #include <signal.h> void signal_handler(int signum){ // signal handler function for key strokes and different events if(signum == SIGINT ) { // ctrl+C pressed // insert your command to close serial exit(-3); // echoes -3 for ^C (ASCII 3) } } int main() { signal...
by 1dot0
Tue Sep 26, 2017 5:20 pm
Forum: Raspbian
Topic: USB touchscreen drivers for ASUS VT168N touch screen monitor
Replies: 0
Views: 792

USB touchscreen drivers for ASUS VT168N touch screen monitor

does someone know if Raspbian (Jessie) supports the USB touchscreen functionality of the ASUS VT168N touch screen monitor?
by 1dot0
Tue Sep 26, 2017 6:42 am
Forum: C/C++
Topic: This python code in C
Replies: 11
Views: 2032

Re: This python code in C

@swagsquad: I wrote a little function serialGets() which reads a line from serial (USB, or UART) and hopefully works for you (admittedly not tested yet): https://www.raspberrypi.org/forums/viewtopic.php?f=33&t=193996&p=1215228#p1215201 Just insert the correct serial USB path into the serialOpen() fu...
by 1dot0
Mon Sep 25, 2017 5:41 pm
Forum: C/C++
Topic: wiringPi wringSerial int fd=serialOpen() versus FILE *fp=fopen()
Replies: 9
Views: 2403

Re: wiringPi wringSerial int fd=serialOpen() versus FILE *fp=fopen()

I don't think it was NUL terminating the string for the normal case though. Why do you have to call serialDataAvailable() each time, doesn't serialGetchar() block? I tried to sort of mimic fgets with respect to 0-terminating fgets char * fgets ( char * str, int num, FILE * stream ); Get string from...
by 1dot0
Mon Sep 25, 2017 4:27 pm
Forum: C/C++
Topic: wiringPi wringSerial int fd=serialOpen() versus FILE *fp=fopen()
Replies: 9
Views: 2403

Re: wiringPi wringSerial int fd=serialOpen() versus FILE *fp=fopen()

will this be ok? // serialGets() // read line from serial // Reads characters and stores them as a C string into str // until (maxlen-1) characters have been read (start counting at 0) // or either a newline // or the end-of-file is reached, whichever happens first. // requires wiringSerial.h // ret...
by 1dot0
Mon Sep 25, 2017 3:44 pm
Forum: C/C++
Topic: wiringPi wringSerial int fd=serialOpen() versus FILE *fp=fopen()
Replies: 9
Views: 2403

Re: wiringPi wringSerial int fd=serialOpen() versus FILE *fp=fopen()

yes, I agree, I was missing the facts about buffers and all that. I thought I could easily apply those functions to serial0 like to other files ("to C all files are equal, but some are more equal than others" ;) )
by 1dot0
Mon Sep 25, 2017 3:20 pm
Forum: C/C++
Topic: wiringPi wringSerial int fd=serialOpen() versus FILE *fp=fopen()
Replies: 9
Views: 2403

Re: wiringPi wringSerial int fd=serialOpen() versus FILE *fp=fopen()

there are no fgets and no fscanf available (reading strings, reading formatted data)
But after all, fgets and fscanf are absolutely standard C functions, why shoudn't they be safe?
by 1dot0
Mon Sep 25, 2017 11:01 am
Forum: C/C++
Topic: wiringPi wringSerial int fd=serialOpen() versus FILE *fp=fopen()
Replies: 9
Views: 2403

Re: wiringPi wringSerial int fd=serialOpen() versus FILE *fp=fopen()

so DIUYC, first use int fd = serialOpen (device, baud) ; to get a valid fd, and have access to the wiringSerial functions via fd, and then afterwards additionally (passing that fd) FILE * pFile = fdopen(fd, mode); to get a valid pFile additionally, to use fgets or fscanf via the pFile pointer? and c...
by 1dot0
Mon Sep 25, 2017 10:28 am
Forum: C/C++
Topic: wiringPi wringSerial int fd=serialOpen() versus FILE *fp=fopen()
Replies: 9
Views: 2403

wiringPi wringSerial int fd=serialOpen() versus FILE *fp=fopen()

opening files via fopen() is returning a FILE pointer FILE * fopen ( const char * filename, const char * mode ); this FILE* is used then for stdio.h functions to access that opened file. OTOH, wiringSerial uses serialOpen() returning an int int serialOpen (char *device, int baud) ; it uses that int ...
by 1dot0
Mon Sep 25, 2017 8:20 am
Forum: C/C++
Topic: This python code in C
Replies: 11
Views: 2032

Re: This python code in C

especially if you want to use them in anything other than a trivial way decided by someone else.
do you mean Gordon Henderson's wiringPi / wiringSerial by that?
by 1dot0
Mon Sep 25, 2017 7:58 am
Forum: C/C++
Topic: This python code in C
Replies: 11
Views: 2032

Re: This python code in C

I agree that a beginner programmer might like something a bit easier to use of the bat. A library like wiringPi for example. one should always presuppose that users asking programming questions in this forum section are actually beginners. Especially, if they ask how to port Python code of a serial...
by 1dot0
Sun Sep 24, 2017 4:53 pm
Forum: C/C++
Topic: This python code in C
Replies: 11
Views: 2032

Re: This python code in C

Everything you need to know about using serial ports from C in Linux, complete with code examples, is here: https://www.cmrr.umn.edu/~strupp/serial.html I honestly doubt that https://www.cmrr.umn.edu/~strupp/serial.html is all one needed to know. As for beginners to C (as one the OP is supposed to ...
by 1dot0
Sun Sep 24, 2017 9:01 am
Forum: C/C++
Topic: This python code in C
Replies: 11
Views: 2032

Re: This python code in C

I tried to make fgets() work with wiringPi/wiringSerial http://wiringpi.com/reference/serial-library/ ,
but the code I first wrote didn't work actually, so I deleted the code.
So I have to resign, too.
One would need to have a
serialReadln()
or
serialReadUntil()
in wiringPi
by 1dot0
Sun Sep 24, 2017 8:28 am
Forum: C/C++
Topic: This python code in C
Replies: 11
Views: 2032

Re: This python code in C

edit, did not work
by 1dot0
Thu Sep 21, 2017 7:57 am
Forum: C/C++
Topic: help getting my program launched on the pi zero w
Replies: 14
Views: 1974

Re: help getting my program launched on the pi zero w

ok, thanks, that makes it more clear to me. OTOH, 1st, the program is using namespace std; 2nd, which are examples for a global namespace in those mentioned libs opposite to the standard namespace, and what is that at all (given one would not define one's own proprietary namespace in a proprietary c...
by 1dot0
Wed Sep 20, 2017 5:35 pm
Forum: C/C++
Topic: help getting my program launched on the pi zero w
Replies: 14
Views: 1974

Re: help getting my program launched on the pi zero w

so in short words, IIUC:
compiling gcc C will need libname.h
whilst g++ C++ will need clibname.

That would mean, as it's C++ code above, all the libname.h #includes can be dropped, correct?
by 1dot0
Wed Sep 20, 2017 7:15 am
Forum: C/C++
Topic: help getting my program launched on the pi zero w
Replies: 14
Views: 1974

Re: help getting my program launched on the pi zero w

Not quite, there is a difference. For the C standard header files functions / types etc. are in the global namespace in the C named headers (e.g. stdlib.h) whereas they are in the std namespace in the C++ named headers (e.g. cstdlib). Either can define them in both namespaces but they don't have to...
by 1dot0
Tue Sep 19, 2017 3:58 pm
Forum: C/C++
Topic: help getting my program launched on the pi zero w
Replies: 14
Views: 1974

Re: help getting my program launched on the pi zero w

for message 1, of course there must be a file m11.wav !

and for msg 2, there is a white space missing between aplay and your file name l7.wav to play: check your source code!
by 1dot0
Tue Sep 19, 2017 3:42 pm
Forum: C/C++
Topic: help getting my program launched on the pi zero w
Replies: 14
Views: 1974

Re: help getting my program launched on the pi zero w

basically, stdlib.h is for the system call ( https://linux.die.net/man/3/system ) , iostream is for pipelining console io commands cout << cin ( http://www.cplusplus.com/reference/iostream/ ) (actually not needed in the short pattern, but in yodakohl's original code) stdlib.h is actually an alias fo...

Go to advanced search