Go to advanced search

by PiGraham
Tue Jun 02, 2020 10:48 am
Forum: C/C++
Topic: Can anybody help me troubleshoot an "if" statement?
Replies: 24
Views: 514

Re: Can anybody help me troubleshoot an "if" statement?

Passing a reference to a single char to string functions causes serious problems because it typically results in attempts to access addresses that are not in allocated data. char reply; // one character allocated scanf("%s",&reply); // read a string of characters and attempt to store them all starti...
by PiGraham
Tue Jun 02, 2020 10:38 am
Forum: C/C++
Topic: Can anybody help me troubleshoot an "if" statement?
Replies: 24
Views: 514

Re: Can anybody help me troubleshoot an "if" statement?

You need to reserve space for the reply and pass a pointer to that space to the scanf and strcmp functions. char reply; // this is just a small integer to represent one character char name[30]; // this is an array of 30 small integers to hold a string of characters char *string = name; // This is a ...
by PiGraham
Tue Jun 02, 2020 9:53 am
Forum: Beginners
Topic: Monitor GPIO inputs
Replies: 8
Views: 187

Re: Monitor GPIO inputs

Doccumentation for GPIOZero gives examples of button inputs and LED outputs programmed in Python: https://gpiozero.readthedocs.io/en/stable/api_input.html https://gpiozero.readthedocs.io/en/stable/api_output.html The LED class even has a Blink method you could use to do the on for 10 seconds bit. Th...
by PiGraham
Mon Jun 01, 2020 10:05 pm
Forum: Beginners
Topic: Monitor GPIO inputs
Replies: 8
Views: 187

Re: Monitor GPIO inputs

If that is the only functionality required then a RPi (any model) is gross overkill. even an arduino (any kind) would be overkill. More importantly, what programming language are you using? can you post what you have (between code /code tags...) A beginner has a Pi and is learning what can be done ...
by PiGraham
Mon Jun 01, 2020 6:35 pm
Forum: Advanced users
Topic: multiple BT connection
Replies: 12
Views: 281

Re: multiple BT connection

by PiGraham
Mon Jun 01, 2020 6:32 pm
Forum: Advanced users
Topic: multiple BT connection
Replies: 12
Views: 281

Re: multiple BT connection

what to read data (in this case CPU temperature) with multiple device from the Pi. ATM if I connect with nRF Connect to the PI with a smartphone I can't connect another smartphone without disconnect before the first one You don't need connection for that, you can put temperature and more informatio...
by PiGraham
Mon Jun 01, 2020 4:15 pm
Forum: C/C++
Topic: Can anybody help me troubleshoot an "if" statement?
Replies: 24
Views: 514

Re: Can anybody help me troubleshoot an "if" statement?

The error message from the Geany compiler was - Warning: implicit declaration of function ‘strncmp’ [-wimplicit-function-declaration] ou need to include header files for library functions you use and you may need to explicitly specify lib files containing those functions. For strncmp or strcasecmp ...
by PiGraham
Mon Jun 01, 2020 9:35 am
Forum: C/C++
Topic: Can anybody help me troubleshoot an "if" statement?
Replies: 24
Views: 514

Re: Can anybody help me troubleshoot an "if" statement?

BTW, a comment on this thread in general. What is the overall goal? I don't see why someone would want to write this sort of program in C. Only that that seemed to be what was used in the OP (posted in c/c++ forum using main() & stdio functions) There are many better (friendlier) ways to go. Using ...
by PiGraham
Mon Jun 01, 2020 7:15 am
Forum: C/C++
Topic: Can anybody help me troubleshoot an "if" statement?
Replies: 24
Views: 514

Re: Can anybody help me troubleshoot an "if" statement?

There were people in the past who thought that 0 == x was safer than x == 0 because if an '=' was accidentally missed it became an assignment and that needs an lvalue. Did I miss the memo outlawing this convention (quite likely)? == is commutative. Either way round reads the same to me, but opinion...
by PiGraham
Mon Jun 01, 2020 7:10 am
Forum: C/C++
Topic: Can anybody help me troubleshoot an "if" statement?
Replies: 24
Views: 514

Re: Can anybody help me troubleshoot an "if" statement?

https://www.gnu.org/software/gperf GNU gperf is a perfect hash function generator. For a given list of strings, it produces a hash function and hash table, in form of C or C++ code, for looking up a value depending on the input string. The hash function is perfect, which means that the hash table h...
by PiGraham
Sun May 31, 2020 8:47 pm
Forum: C/C++
Topic: Can anybody help me troubleshoot an "if" statement?
Replies: 24
Views: 514

Re: Can anybody help me troubleshoot an "if" statement?

Incoming typed info can be stored as null terminated byte arrays, the bytes can be summed together to produce a semi-unique number that can be sent to the switch case to be used as an input to the switch array. As a byte array holds only 0-255, add the numbers in a regular int, so as not to create ...
by PiGraham
Sun May 31, 2020 8:42 pm
Forum: C/C++
Topic: Can anybody help me troubleshoot an "if" statement?
Replies: 24
Views: 514

Re: Can anybody help me troubleshoot an "if" statement?

jahboater wrote:
Sun May 31, 2020 6:26 pm

Code: Select all

if( !strncmp( reply, "Fine", 4 ) )
the "0 == strcmp" thing is quite gastly :(
:lol:
True, but the return is not a bool. Using ! on an int isn't exactly the most elegant thing either.
by PiGraham
Sun May 31, 2020 3:13 pm
Forum: C/C++
Topic: Can anybody help me troubleshoot an "if" statement?
Replies: 24
Views: 514

Re: Can anybody help me troubleshoot an "if" statement?

I have literally tried 100 different variations of code based on 2 examples that I have found. This is a nice simple version that compiles and I don’t understand why it wouldn’t work but it doesn’t. The code I am trying is as follows. #include <stdio.h> int main (void) { char name [30]; char reply;...
by PiGraham
Sun May 31, 2020 6:31 am
Forum: General discussion
Topic: Raspbian rename to Raspberry Pi OS - a bad idea?
Replies: 78
Views: 2449

Re: Raspbian rename to Raspberry Pi OS - a bad idea?

So will PIOS32 and PIOS64 be essentially identical to users? People might expect them to be the same code base and config but built either for 32 or 64 bit. Or are they going to be two quite distinct distros? It might be a good idea to promote a tag name to aid searches. Raspberry Pi OS will throw u...
by PiGraham
Fri May 29, 2020 2:20 pm
Forum: Advanced users
Topic: multiple BT connection
Replies: 12
Views: 281

Re: multiple BT connection

The limitation for standard BT is 7 device to a master (in BLE it is teorically 65k). you can't connect your phone to multiple speaker not for BT limitation but just cuz in phones is implemented like this (and this is not entirelly true cuz you can connect to the PI and listen music with speaker at...
by PiGraham
Fri May 29, 2020 10:25 am
Forum: General discussion
Topic: Reducing Servo Jitter
Replies: 18
Views: 564

Re: Reducing Servo Jitter

I have the same problem following the above hasn't really helped much still jittery Im using a cheap servo is this the problem? https://www.rclife.co.uk/RC-Spares/Servos/Corona-CS-918MP-Analog-Servo-9g FYI How much "jitter"? what is the servo connected to? Any drive system can hunt around the set p...
by PiGraham
Fri May 29, 2020 10:17 am
Forum: Advanced users
Topic: multiple BT connection
Replies: 12
Views: 281

Re: multiple BT connection

what to read data (in this case CPU temperature) with multiple device from the Pi. ATM if I connect with nRF Connect to the PI with a smartphone I can't connect another smartphone without disconnect before the first one I don't know, but is that a general limitation of Bluetooth devices? I can't co...
by PiGraham
Thu May 28, 2020 5:00 pm
Forum: Beginners
Topic: DC Motor Driving
Replies: 4
Views: 118

Re: DC Motor Driving

I am working on a project to assist in driving a linear guide rail using a DC stepper motor Do you mean a unipolar stepper motor (e.g. 28BYJ-48) with five wires, one being the common centre point of all coils? Most steppers are bipolar with H-bridge drivers creating alternating current in the coils...
by PiGraham
Fri May 22, 2020 8:20 am
Forum: C/C++
Topic: program gets stock in a keypad function.
Replies: 3
Views: 147

Re: program gets stock in a keypad function.

Does the code detect kepad presses? It looks like it's intended to have the input row gpios with pullups and the column outputs initialised to high Do you do that? Is the keypad wired correctly? If you just set one col gpio low and repeatedly read one row input does the state change when you press t...
by PiGraham
Thu May 21, 2020 3:57 pm
Forum: General discussion
Topic: Very simple OTG on pi4
Replies: 32
Views: 14088

Re: Very simple OTG on pi4

I think it depends. YMMV. Indeed. Reading this might help: https://www.raspberrypi.org/documentation/hardware/raspberrypi/power/README.md Indeed. Typical bare-board active current consumption 600mA So a Pi just acting as a keyboard, or maybe just an SD card based storage, might be OK. But don't get...
by PiGraham
Thu May 21, 2020 3:48 pm
Forum: General discussion
Topic: Very simple OTG on pi4
Replies: 32
Views: 14088

Re: Very simple OTG on pi4

this can't work I plugged my pi4 with an usb C cable , the computer cant even power the PI you need a Y split cable It can work. I had no problem powering the Pi4 from my PC USB3 port and running it as a keyboard gadget. It may not work in that configuration for everyone, and there are certainly th...
by PiGraham
Thu May 21, 2020 1:55 pm
Forum: Beginners
Topic: running two scripts at the same time
Replies: 10
Views: 253

Re: running two scripts at the same time

Here is the code on pastebin, I have tried rewriting motorTest to function also and return speed to app.py but it didnt work also. codes: https://pastebin.com/PQSJPJ5b -> app.py https://pastebin.com/b3rAmrQk -> motorTest.py https://pastebin.com/5FyefNZJ -> tabs.html How is MotorTest.py communicatin...
by PiGraham
Thu May 21, 2020 10:13 am
Forum: Camera board
Topic: Raspberry Pi High Quality Camera Long Exposures
Replies: 50
Views: 2484

Re: Raspberry Pi High Quality Camera Long Exposures

RoboRob wrote:
Thu May 21, 2020 9:58 am

Thanks for your response, I'm so puzzled with the behgaviour of this camera (using raspistill or the picamera libraries)!
Does this help?

https://www.raspberrypi.org/documentati ... /camera.md
by PiGraham
Wed May 20, 2020 2:10 pm
Forum: General discussion
Topic: Product recommendation needed - RS485, WiFi
Replies: 1
Views: 51

Re: Product recommendation needed - RS485, WiFi

There are plenty of USB RS485 interfaces you could use with any Pi.

Maybe Google can help:

https://widgetlords.com/products/pi-spi ... -interface
by PiGraham
Wed May 20, 2020 9:41 am
Forum: Python
Topic: Adding a Delay in a tkinter program
Replies: 10
Views: 259

Re: Adding a Delay in a tkinter program

RDS wrote:
Wed May 20, 2020 7:55 am
@PiGraham
That sounded interesting until I reached the 'subscription' part.
It makes the point. I'm sure you can find some further reading if you want to learn more. Google some of the words in the preview text.
You could use the free trial.

Go to advanced search