Hobbyist Toolkit

cancel
Showing results for 
Search instead for 
Did you mean: 

RPi 4B GPIO access on GPIO 14 (Pin 08) and GPIO 15 (Pin 10)

I'm working on a project board that has digital inputs on GPIO 14, 15, and 23 (FreeNove 4WD smart car for Raspberry Pi). The issue is that I'm not able to access GPIO 14 and 15 (Pins 8 and 10) as these are not available in the Linx Hobbyist toolkit under Digital Read. I was wondering if there is an update or work around, as I would like to leave the hardware as is and not move to avaiable GPIO pins.

 

From what I gather the following are the only pins directly available: 

 

Pins (not GPIO number)

7,11,12,13,15,16,18,22,29,31,32,33,35,36,37,38,40

 

0 Kudos
Message 1 of 8
(2,334 Views)

This is correct and hardwired in the liblinxdevice.so library used by the RaspberryPi target. The reason for that is that these pins are used for the UART (TXD0/RXD0) and also initialized as such, which makes them unavailable as GPIO pins.

 

You would have to edit the files vi.lib/MakerHub/LINX/Firmware/Source/core/device/LinxRaspberryPi2B.cpp and vi.lib/MakerHub/LINX/Firmware/Source/core/device/LinxRaspberryPi2B.h accordingly and then recompile the Linx shared library and copy them onto your Raspberry Pi in order to allow for these pins to be available as GPIO.

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 8
(2,260 Views)

Thank you very much for this information. Since I'm using the network connection I may just go ahead and modify the file.

0 Kudos
Message 3 of 8
(2,251 Views)

Rolf Kalbermatter

     Thank you for your help. I followed your instructions and was able to compile and share. I used the following commands

 

g++ -c -o LinxRaspberryPi2B.o LinxRaspberryPi2B.cpp

gcc -shared -o libLV_2835.so LinxRaspberryPi2B.o

 

then used 

  • chmod 755 libLV_2835.so 
  • cp libLV_2835.so /usr/lib/
  • and then verified the file had updated.

 

I made the following change to the cpp file.

//DIGITAL
/****
const unsigned char LinxRaspberryPi2B::m_DigitalChans[NUM_DIGITAL_CHANS] = {7, 11, 12, 13, 15, 16, 18, 22, 29, 31, 32, 33, 35, 36, 37, 38, 40};
const unsigned char LinxRaspberryPi2B::m_gpioChan[NUM_DIGITAL_CHANS] =     {4, 17, 18, 27, 22, 23, 24, 25, 5, 6, 12, 13, 19, 16, 26, 20, 21};
**/

 

const unsigned char LinxRaspberryPi2B::m_DigitalChans[NUM_DIGITAL_CHANS] = {7, 8, 10, 11, 12, 13, 15, 16, 18, 22, 29, 31, 32, 33, 35, 36, 37, 38, 40};
const unsigned char LinxRaspberryPi2B::m_gpioChan[NUM_DIGITAL_CHANS] =     {4, 14, 15, 17, 18, 27, 22, 23, 24, 25, 5, 6, 12, 13, 19, 16, 26, 20, 21};

 

and 

and updated the header:

/** #define NUM_DIGITAL_CHANS 17 */
#define NUM_DIGITAL_CHANS 19

 

I made sure to have a working copy of the .so on both the RPi and Win 10 system. 

When tested it in LabVIEW, it did not appear to update the valid pins as the property node is still listing the original 17 pins and says that pin 8 is not valid. 

 

Is there something that I've overlooked or forgotten to update and the LabVIEW side? 

I've included the files I modified.

Download All
0 Kudos
Message 4 of 8
(2,231 Views)

It would appear that i mixed up Linx and a second labVIEW plug-in I had installed. I'm working on where to place the updated LinxRaspberryPi2B.so and then try it again.

0 Kudos
Message 5 of 8
(2,226 Views)

It’s not quite as trivial. The shared library is called liblinxdevice.so and consists of a “little” more than just the compiled source file for the Raspberry PI part.

Basically you need to compile it with either a cross compiler installation for the ARM eabi soft-fp used in the Raspberry PI LabVIEAw chroot or directly in the Raspberry Pi LabVIEW chroot after installing dev-essentials on it.

There are Makefiles in the various directories so it should be enough to enter simply “make” on the commandline once you are in the top directory for the sources.

Rolf Kalbermatter
My Blog
0 Kudos
Message 6 of 8
(2,204 Views)

Rolf Kalbermatter,

    Thank you for the help you provided as this took us in the right direction. The issue that we are having now are errors during the MAKE process. The following is the command line used, as well as the resulting output/errors. I will fully understand if this is something that is beyond a simple response but any help or direction would be useful, as I think we are getting closer to it working.

 

FYI: I moved the MakerHub folder to the raspberry pi and have been using the RPi to compile and run Make. I also made sure that dev-essentials has been installed on the RPi.

 

******************************************Command line and Error Message to Follow*************************************

 

pi@raspberrypi:~/MakerHub/LINX/Firmware/Source/make $ sudo make

g++    -I../core/device/utility -I../core/device/ -I../core/listener -Wall -shared -fPIC -lrt -o ../core/examples/LinxDeviceLib/bin/liblinxdevice_rpi2.so ../core/examples/LinxDeviceLib/src/LinxDeviceLib.cpp ../core/device/utility/LinxDevice.cpp ../core/device/utility/LinxRaspberryPi.cpp ../core/device/LinxRaspberryPi2B.cpp -DLINX_DEVICE_FAMILY=4 -DLINX_DEVICE_ID=3 -DLINXCONFIG -DDEBUG_ENABLED=-1 -g

../core/examples/LinxDeviceLib/src/LinxDeviceLib.cpp: In function ‘int LinxGetDeviceName(std::string*)’:

../core/examples/LinxDeviceLib/src/LinxDeviceLib.cpp:65:58: warning: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘std::string’ {aka ‘class std::__cxx11::basic_string<char>’} with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Wclass-memaccess]

   65 |  memcpy(name, LinxDev->DeviceName, LinxDev->DeviceNameLen);

      |                                                          ^

In file included from /usr/include/c++/10/string:55,

                 from /usr/include/c++/10/bits/locale_classes.h:40,

                 from /usr/include/c++/10/bits/ios_base.h:41,

                 from /usr/include/c++/10/ios:42,

                 from /usr/include/c++/10/ostream:38,

                 from /usr/include/c++/10/iostream:39,

                 from ../core/examples/LinxDeviceLib/src/LinxDeviceLib.cpp:13:

/usr/include/c++/10/bits/basic_string.h:77:11: note: ‘std::string’ {aka ‘class std::__cxx11::basic_string<char>’} declared here

   77 |     class basic_string

      |           ^~~~~~~~~~~~

In file included from ../core/device/utility/LinxRaspberryPi.cpp:30:

../core/device/termios.h:20:3: error: #error "Never include <bits/termios.h> directly; use <termios.h> instead."

   20 | # error "Never include <bits/termios.h> directly; use <termios.h> instead."

      |   ^~~~~

../core/device/utility/LinxRaspberryPi.cpp: In member function ‘virtual int LinxRaspberryPi::UartSetBaudRate(unsigned char, long unsigned int, long unsigned int*)’:

../core/device/utility/LinxRaspberryPi.cpp:658:2: error: ‘tcgetattr’ was not declared in this scope

  658 |  tcgetattr(UartHandles[channel], &options);

      |  ^~~~~~~~~

../core/device/utility/LinxRaspberryPi.cpp:665:2: error: ‘tcflush’ was not declared in this scope; did you mean ‘fflush’?

  665 |  tcflush(UartHandles[channel], TCIFLUSH);

      |  ^~~~~~~

      |  fflush

../core/device/utility/LinxRaspberryPi.cpp:666:2: error: ‘tcsetattr’ was not declared in this scope

  666 |  tcsetattr(UartHandles[channel], TCSANOW, &options);

      |  ^~~~~~~~~

In file included from ../core/device/LinxRaspberryPi2B.cpp:15:

../core/device/termios.h:20:3: error: #error "Never include <bits/termios.h> directly; use <termios.h> instead."

   20 | # error "Never include <bits/termios.h> directly; use <termios.h> instead."

      |   ^~~~~

make: *** [Makefile:28: raspberryPi2BLib] Error 1

0 Kudos
Message 7 of 8
(2,163 Views)

It would appear that you do the compilation on the Raspberry Pi host but you need to do it inside the LabVIEW schroot. And there you have to work with opkg on the command line to install packages from the NI feeds.

 

https://www.labviewmakerhub.com/doku.php?id=learn:tutorials:libraries:linx:misc:build-on-target

 

Even if you would manage to compile the shared library on the Raspberry Pi host, it would not be ABI compatible with the LabVIEW schroot environment.

Rolf Kalbermatter
My Blog
0 Kudos
Message 8 of 8
(2,155 Views)