Go to advanced search

by gordon@drogon.net
Fri Oct 13, 2017 5:09 pm
Forum: C/C++
Topic: WiringPi Serial help
Replies: 8
Views: 386

Re: WiringPi Serial help

Hi 1dot0, thank you for the reply. 1) if it can never be -1, what then should i put instead? Well - firstly you ought to use CODE tags round the code - it makes it easier for people to read. then you need to start reading the fine manuals where it tells you what the return code is - it's an integer...
by gordon@drogon.net
Fri Oct 13, 2017 1:56 pm
Forum: C/C++
Topic: WiringPi Serial help
Replies: 8
Views: 386

Re: WiringPi Serial help

you should check the return code from serialOpen(), however that's not your issue - the issue is that output is buffered until you print a new line, so either append a newline \n to the printf() or call fflush (stdout); after the printf() call.

-Gordon
by gordon@drogon.net
Mon Oct 02, 2017 8:58 am
Forum: Other languages
Topic: Porting ARM BASIC to the Raspberry Pi via SDL 2.0
Replies: 89
Views: 9233

Re: Porting ARM BASIC to the Raspberry Pi via SDL 2.0

Having checked out the data file input capabilities of both RTB and FUZE Basic [sic], I found that it seems they are not really capable of reading binary data which would appear in an image file. Just as I was determining that RTB and FUZE Basic [sic] would not likely be able to serve my needs, I d...
by gordon@drogon.net
Sun Oct 01, 2017 11:25 am
Forum: C/C++
Topic: Closing serial port when doing ^C
Replies: 4
Views: 618

Re: Closing serial port when doing ^C

I'm somewhat confused here - when you ^C a program, all files are automatically closed. This includes things like serial ports. You can not normally leave files open when your program terminates. So it sounds like something else is going on. When serialOpen() returns -1, then errno will be set - it ...
by gordon@drogon.net
Tue Sep 26, 2017 2:23 pm
Forum: C/C++
Topic: Serial Port RAW mode
Replies: 5
Views: 514

Re: Serial Port RAW mode

Code: Select all

#include <wiringSerial.h>

...

  fd = serialOpen ("/dev/ttyUSB0", 115200) ;
  ...
  while (serialDataAvail (fd))
  {
  ... do stuff, etc.
  }
From the "make life easy for you" department.
-Gordon
by gordon@drogon.net
Wed Sep 20, 2017 8:56 am
Forum: C/C++
Topic: Simple GPIO access in C
Replies: 25
Views: 21698

Re: Simple GPIO access in C

One if the issues using your own hardware poking is that you need to be aware of a few things - and one is that the hardware address is not the same over all Pi models. It changed. That's one reason to use someone elses library - they all detect the change for you. e.g. using wiringPi, #include <wir...
by gordon@drogon.net
Thu Sep 14, 2017 1:15 pm
Forum: C/C++
Topic: Unable to read Pi input
Replies: 3
Views: 275

Re: Unable to read Pi input

Hi everyone, So I am trying to read in the state of a PWM MA3 absolute rotary encoder with the Raspberry Pi. When I run the code below, only values of zero are being printed. When I run the Python equivalent code, I get a series of ones and zeros, so I'm not sure what I am doing wrong with the C co...
by gordon@drogon.net
Wed Sep 13, 2017 2:31 pm
Forum: C/C++
Topic: GPIO: should I learn sysfs or direct register access?
Replies: 3
Views: 360

Re: GPIO: should I learn sysfs or direct register access?

Make life easy for yourself and use a library - there are a couple to choose from. wiringPi (mine) and PiGPIO are the popular ones. both include command-line tools to let you do stuff without even writing a program. e.g. in wiringPi - blink an LED on physical pin 11: gpio -1 blink 11 (the -1 tells i...
by gordon@drogon.net
Wed Aug 16, 2017 10:03 am
Forum: General programming discussion
Topic: Not able to turn a pin to be zero
Replies: 3
Views: 468

Re: Not able to turn a pin to be zero

If you are using the Kernel SPI driver (either directly or via the wiringPi helpers, or some other library) then you should not. ever. touch the pins directly with pinMode(), exports, digitalWrite(), etc. Leave them to the kernel. Don't even read the pin states as it's of no-use to you whatsoever. E...
by gordon@drogon.net
Thu Aug 10, 2017 8:58 pm
Forum: C/C++
Topic: Sampling with C and MCP3008
Replies: 8
Views: 833

Re: Sampling with C and MCP3008

There are several strategies - however the Linux thing might be more a limitation - remember the Pi is running a multi-user, multi-tasking operating system - it's not a microcontroller running your dedicated code and nothing else.... For for fixed rate sampling, one strategy is to calculate the next...
by gordon@drogon.net
Thu Aug 10, 2017 8:48 pm
Forum: C/C++
Topic: I2C LCD Display Library
Replies: 8
Views: 877

Re: I2C LCD Display Library

you might want to look at wiringPi - if your display is one of the usual ones with the hitachi or compatible display. http://wiringpi.com/dev-lib/lcd-library/ The way to use this via an I2C GPIO expander is to first include the expander into wiringPi's pin system, then work out the pins to use in yo...
by gordon@drogon.net
Sun Aug 06, 2017 11:20 am
Forum: C/C++
Topic: Error linking lib wiringPi
Replies: 13
Views: 1107

Re: Error linking lib wiringPi

PeterO -> I'm using the command the example give : gcc -Wall -o blink blink.c -lwiringPi Gordon -> I'm running on Raspbian. I was working some years ago with RPIO and PMW to run a motor. But with the time, the lib seems to be not maintained anymore so I cannot continue my work with it. So I searche...
by gordon@drogon.net
Mon Jul 31, 2017 12:47 pm
Forum: C/C++
Topic: Error linking lib wiringPi
Replies: 13
Views: 1107

Re: Error linking lib wiringPi

I got an error trying to run a small example program find on wiringPi website ( http://wiringpi.com/examples/blink/ ). No error occured during installation of the lib. Here the error : /usr/lib/gcc/arm-linux-gnueabihf/4.9/../../../arm-linux-gnueabihf/crt1.o: In function `_start': /build/glibc-P1SmL...
by gordon@drogon.net
Sun Jul 30, 2017 9:20 pm
Forum: C/C++
Topic: MCP23S17, Wiringpi or another library
Replies: 14
Views: 873

Re: MCP23S17, Wiringpi or another library

  OK, thanks, I understand. Then after config both MCP in same program, I access to status of each pin with the base1 and base2 fields ? Do not understand yet how work this of BASE field when setup MCP. I see one example where assign #define BASE 123, and seem that access to each pin with BASE + pi...
by gordon@drogon.net
Sat Jul 29, 2017 6:16 pm
Forum: C/C++
Topic: MCP23S17, Wiringpi or another library
Replies: 14
Views: 873

Re: MCP23S17, Wiringpi or another library

wiringPi can handle 16 mcp12s17's on the standard SPI port on a Raspberry Pi. I'm not seeing where your issue is. In mcp23s17Setup(), there are 3 parameters: pinBase, spiPort and devId. The pinBase is the new pin number of the first pin of the device - any number >= 64 that you like. The spiPort is ...
by gordon@drogon.net
Mon Jul 24, 2017 8:40 am
Forum: C/C++
Topic: DHT22 and mcp3208 has crash?
Replies: 1
Views: 254

Re: DHT22 and mcp3208 has crash?

Not sure what you're doing however, just a few FIY's: wiringPiSetup() will always return TRUE, or it will halt your program. There is no point checking for a return code. See http://wiringpi.com/reference/setup/ wiringPi supports the mcp3008 - it's the mcp3004 driver, just: #include <mcp3004.h> ... ...
by gordon@drogon.net
Wed Jul 19, 2017 8:55 pm
Forum: C/C++
Topic: RaspberryPi C++ Blog
Replies: 26
Views: 1750

Re: RaspberryPi C++ Blog

Great! Just a few points... wiringPi is written in C, not C++. Your program is C, not C++ (although at this level it's hardly an issue) wiringPi is normally installed at standard with Raspbian, no need to download and compile. Building it as you have done will result in both the installed version an...
by gordon@drogon.net
Mon Jun 26, 2017 4:24 pm
Forum: Beginners
Topic: RTB & wiringPi on Pi 3 Model B versus the older Pi Model B+
Replies: 13
Views: 722

Re: RTB & wiringPi on Pi 3 Model B versus the older Pi Model

I certainly would be interested in hearing that someone succeeds at making this work with RTB and how it is accomplished. While FUZE BASIC can do what I want, as I mentioned, I prefer the clean look of the RTB system. I appreciate your enthusiasm, however please stop making text big and bold. It's ...
by gordon@drogon.net
Mon Jun 26, 2017 8:12 am
Forum: Beginners
Topic: RTB & wiringPi on Pi 3 Model B versus the older Pi Model B+
Replies: 13
Views: 722

Re: RTB & wiringPi on Pi 3 Model B versus the older Pi Model

Make sure you have wiringPi version 2.44. Other than that it all ought to be fine.

I did get your email, but have been somewhat busy the past week - I'll reply soon.

-Gordon
by gordon@drogon.net
Fri Jun 23, 2017 1:19 pm
Forum: C/C++
Topic: wiringPiI2CWriteReg16() and Arduino discrepancies
Replies: 4
Views: 375

Re: wiringPiI2CWriteReg16() and Arduino discrepancies

The problem was in my Arduino code. Gordon tipped me off that the bytes are read in separately, LSB first. Throughout all of my searching, I hadn't come across that, and really didn't quite understand what was happening. To be pedantically correct; they are sent LSB first. Who knows what's on the o...
by gordon@drogon.net
Fri Jun 23, 2017 10:41 am
Forum: C/C++
Topic: wiringPiI2CWriteReg16() and Arduino discrepancies
Replies: 4
Views: 375

Re: wiringPiI2CWriteReg16() and Arduino discrepancies

Hi all, Long time lurker, first question. I am the author of WiringPi::API Perl wrapper for Gordon's wiringPi (amongst a bunch of other RPi related software on the CPAN ). Due to writing and building an automated CI test platform for some of my code, I needed to integrate with an Arduino via I2C fo...
by gordon@drogon.net
Wed Jun 21, 2017 10:56 am
Forum: C/C++
Topic: 16x2 LCD - simple C code
Replies: 12
Views: 3105

Re: 16x2 LCD - simple C code

FWIW: To drive these LCDs "properly", you need to use the R/W pin, and read back the device status rather than rely on software (or kernel) timing routines. However most of these devices are 5v which are fine to be driving from the Pi's 3.3v, as long as you tie the R/W line low, to force the device ...
by gordon@drogon.net
Wed Jun 21, 2017 9:49 am
Forum: C/C++
Topic: 16x2 LCD - simple C code
Replies: 12
Views: 3105

Re: 16x2 LCD - simple C code

When starting to play with it I found various python scripts and a couple of C scripts, but felt they were either unwieldy or hid too much control from the programmer. Personally, I don't find this ... #include <wiringPi.h> #include <lcd.h> #define LCD_E 23 #define LCD_RS 22 #define LCD_D4 24 #defi...
by gordon@drogon.net
Wed Jun 14, 2017 12:03 pm
Forum: C/C++
Topic: Linking WiringPi library in CMakeLists
Replies: 2
Views: 355

Re: Linking WiringPi library in CMakeLists

Just to note that wiringPi is included with Raspbian, but not raspbian-lite, so all you need to do, if it's not installed is simply: sudo apt-get install wiringpi Always best to check before compiling from source as this can cause confusion. Can't help with CMake though - I use old fashioned Makefil...
by gordon@drogon.net
Sun Jun 04, 2017 4:21 pm
Forum: C/C++
Topic: Wiring Pi GPIO Reset
Replies: 10
Views: 10665

Re: Wiring Pi GPIO Reset

Hi all, To reset BCM the UART pins from IN/OUT back to ALT0 i had to use the same command in C: pinModeAlt(#, 0b100) Why is this an undocumented feature ? Paul Because you're using the Pi in a way that the creators didn't envisage. Actually, it is documented - in the Broadcom ARM peripherals book/p...

Go to advanced search