[beagleboard] This is a C++ working code example of using multithreading with semaphores and mutex.

2014-03-28 Thread Patrick Ireland
I did not find a C++ example of multithreading for the BeagleBoardBlack 
when I searched before.
Since I need to validate the use of threading, semaphores, and mutexes on 
my new BeagleBoardBlack I developed this working example.
This example creates 2 different styles of threads (a) the method is the 
thread and (b) the method started as a thread creates a class which the 
method in turn invokes.
I use the second style because I want to easily detect termination problems 
with the thread.
Most of the threads I start for my projects should never return and if they 
do then I need to detect the reason behind the termination.
I have a particular coding style that I have developed over the years (45+) 
of writing code and teaching programming.
You are free to modify the code as you see fit.
My development environment is as follows:
 a) Host computer is PC running Windows 7x64
 b) My source editor is Eclipse and I use the created a remote 
Configuration to upload and test my programs on the BeagleBoardBlack.
 c) Tool chain is SysGCC
 d) I run Putty as an additional terminal to the BeagleBoardBlack.
 e) These are the two sites I use to help me get up and running
  (1) 
http://www.michaelhleonard.com/cross-compile-for-beaglebone-black/
  (2) 
http://learn.adafruit.com/beaglebone-black-installing-operating-systems?view=all
   

If you have any questions, drop me an email at irelan...@embarqmail.com

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to beagleboard+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
/*
 * TestMultiThreading.cpp
 *
 *  Created on: Mar 27, 2014
 *  Author: Pat's Machine
 */

#include 
#include 
#include 
#include 

#define MODULE_NAME"TestMultiThreading"
#define MODULE_AUTHOR  "Patrick Ireland"
#define MODULE_VERSION "2014-03-27 16:30"
#define MOUDLE_PROCESSOR   "BeagleBoneBlack"
#define MODULE_LANGUAGE"C++"
#define MODULE_TYPE"source"
#define MODULE_WHO_AM_I"TMUL"

class TestThread
{
#define ANSWER_TO_THE_UNIVERSE 42

private:
	sem_t* ptrStartSemaphore;
	pthread_mutex_t  * ptrPThreadMutex;

public:
	TestThread(sem_t * argPtrStartSemaphore, pthread_mutex_t * argPtrPThreadMutex)
	{
		printf("%s - ENTER TestThread::TestThread()\n", MODULE_WHO_AM_I);
		ptrStartSemaphore = argPtrStartSemaphore;
		ptrPThreadMutex = argPtrPThreadMutex;
	}   // TestThread()

	~TestThread(void)
	{
	}   // ~TestThread()

	int threadMain(void)
	{
		printf("%s - ENTER TestThread::threadMain()\n", MODULE_WHO_AM_I);
		int executionCount = 0;
		sem_wait(ptrStartSemaphore);
		printf("%s - ENTER TestThread Method loop\n", MODULE_WHO_AM_I);
		while(true)
	{
		pthread_mutex_lock(ptrPThreadMutex);
		printf("%s - method 3 execution %d\n", MODULE_WHO_AM_I, ++executionCount);
		pthread_mutex_unlock(ptrPThreadMutex);
		if (executionCount > 20) break;
		sleep(1);
	}   // while(true)
		pthread_exit(0);
		return(ANSWER_TO_THE_UNIVERSE);
	}   // int threadMain()
};

void * thread1Method(void * argv);
void * thread2Method(void * args);
void * thread3Method(void * argv);

// Used to pass addresses of sem and mutex to threads
typedef struct ThreadData
{
sem_t* ptrSem;
pthread_mutex_t  * ptrMutex;
}  threadData, * ptrThreadData;

#define ARGV_PROGRAM_NAME  0
#define ARGV_COUNT 1

int main (int argc, char ** argv)
{
printf("%s - ENTER %s\n", MODULE_WHO_AM_I, argv[ARGV_PROGRAM_NAME]);
printf("%s - %s version %s\n", MODULE_WHO_AM_I, MODULE_NAME, MODULE_VERSION);
printf("%s - argc = %d\n", MODULE_WHO_AM_I, argc);

for (int idxArgv = 0; idxArgv < argc; idxArgv++)
{
printf ("%s - argv[%d] = %s\n", MODULE_WHO_AM_I, idxArgv, argv[idxArgv]);
}   // for (int idxArgv = 0; idxArgv < argc; idxArgv++)

printf("%s - semaphore inits\n", MODULE_WHO_AM_I);
sem_t  sem1;
sem_t  sem2;
sem_t  sem3;
sem_init(&sem1, 0, 0);
sem_init(&sem2, 0, 0);
sem_init(&sem3, 0, 0);

printf("%s - mutex init\n", MODULE_WHO_AM_I);
pthread_mutex_tmutex;
pthread_mutex_init(&mutex, NULL);

printf("%s - prepare data for threads\n", MODULE_WHO_AM_I);
threadData myData1;
myData1.ptrSem = &sem1;
myData1.ptrMutex = &mutex;

threadData myData2;
myData2.ptrSem = &sem2;
myData2.ptrMutex = &mutex;

threadData myData3;
my

[beagleboard] Interrupts on BBB with either Angstrom or Ubuntu

2014-04-21 Thread Patrick Ireland
With a cursory exploration, it appears that I am unable to attach interrupt 
handlers from C++ code.  Is this indeed true? Is there a hardware 
limitation with the BBB that does not allow interrupts? Though tedious to 
write, I have written Linux device drivers for the Intel architecture but 
that is a dearth of info for the BBB architecture.  I would dearly love to 
add interrupt handlers in C++ with the ease of the Arduino DUE. Before you 
start harping about going back to the Arduino DUE or other mundane 
arguments of DUE vs. BBB, a glaring deficit the Arduino DUE is that the 
operating system does not support multi-threading.  Multi-threading 
separates the embedded  supporting systems from the want-to-bes.  This is 
particularly apparent as the complexity of process control increases.  
However, at this point, BBB appears to have its own issues with external 
interrupt support.  As with multi-threading, need for external interrupt 
support increases as the complexity of the process tneeds increases.   
Unless the external interrupting hardware does not require time critical 
response and has a detectable request time measured in milliseconds (no A 
Priori knowledge of when external hardware needs servicing)  , polling is 
NOT a solution rather a software kludge.  After all this prefacing, what is 
the state of interrupt capabilities from software with the BBB? Can it be 
accomplished with the development of a device driver?  There are multiple 
ways to implement support but only if the underlying hardware of the BBB 
supports such external interrupts.  Will switching from the default 
Angstrom to Ubuntu make any difference?  There are hints of some sort RTOS 
available but does the RTOS have a standard tool chain as available with 
Angstrom and Ubuntu?  Many questions I know, but before beginning a 3 
man-year software development project, they need to be resolved.

Thanks,

Pat Ireland

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to beagleboard+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[beagleboard] How do I cross compile SQLite on my Eclipse/Windows 7 system for BeagleBone Black Rev C?

2014-07-08 Thread Patrick Ireland
I have done ages of C++/C/Java programming on Windows/Linux.
I want to build an app for the BeagleBone Black Rev C that uses SQLite.
I downloaded the source from SQLite.org and build a new project in Eclipse.
I have previously built lots of apps this way for the BeagleBone Black 
series including Rev C.
However, the amalgamated source of SQLite does not build.
It has problems.
I have built successful multithread apps on the BeagleBone Black and have 
many the appropriate include and linkage assignments to the Eclipse Gods 
but I cannot get rid of the pthread_.  undefined problems
nor can I get rid of the dl... undefinded problems.
I want to build the SQLite as an object (not in the OO sense, rather, 
compiled) to be linked in with my eventual application.
Is this the correct way to use SQLite (single application albeit  
multithreaded but I have implemented semaphore access to the eventual 
SQLite portion to avoid multithreading entanglements)?
Has anyone successful cross compiled SQLite from Eclipse/WIndows for the 
BeagleBone Black?

Any suggestions will be greatly appriciated.

./sqlite3.o: In function `pthreadMutexAlloc':
D:\Software 
Development\MyTesting\BeagleBoneBlack\SQLite\Debug/../sqlite3.c:18832: 
undefined reference to `pthread_mutexattr_init'
D:\Software 
Development\MyTesting\BeagleBoneBlack\SQLite\Debug/../sqlite3.c:18833: 
undefined reference to `pthread_mutexattr_settype'
d:/bbb-toolchain/gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/4.8.2/crtbegin.o
D:\Software 
Development\MyTesting\BeagleBoneBlack\SQLite\Debug/../sqlite3.c:18835: 
undefined reference to `pthread_mutexattr_destroy'
./sqlite3.o: In function `pthreadMutexTry':
D:\Software 
Development\MyTesting\BeagleBoneBlack\SQLite\Debug/../sqlite3.c:18964: 
undefined reference to `pthread_mutex_trylock'
./sqlite3.o
./sqlite3.o: In function `unixDlOpen':
-lstdc++ 
(d:/bbb-toolchain/gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/4.8.2/../../../../arm-linux-gnueabihf/lib/libstdc++.so)
D:\Software 
Development\MyTesting\BeagleBoneBlack\SQLite\Debug/../sqlite3.c:29929: 
undefined reference to `dlopen'
./sqlite3.o: In function `unixDlError':
D:\Software 
Development\MyTesting\BeagleBoneBlack\SQLite\Debug/../sqlite3.c:29943: 
undefined reference to `dlerror'
./sqlite3.o: In function `unixDlSym':
-lm 
(d:/bbb-toolchain/gnueabihf/bin/../arm-linux-gnueabihf/libc/usr/lib/arm-linux-gnueabihf/libm.so)
libgcc_s.so.1 
(d:/bbb-toolchain/gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/4.8.2/../../../../arm-linux-gnueabihf/lib\libgcc_s.so.1)
/lib/arm-linux-gnueabihf/libc.so.6 
(d:\bbb-toolchain\gnueabihf\bin\../arm-linux-gnueabihf/libc/lib/arm-linux-gnueabihf/libc.so.6)
(d:\bbb-toolchain\gnueabihf\bin\../arm-linux-gnueabihf/libc/usr/lib/arm-linux-gnueabihf/libc_nonshared.a)elf-init.oS
(d:\bbb-toolchain\gnueabihf\bin\../arm-linux-gnueabihf/libc/usr/lib/arm-linux-gnueabihf/libc_nonshared.a)stat.oS
(d:\bbb-toolchain\gnueabihf\bin\../arm-linux-gnueabihf/libc/usr/lib/arm-linux-gnueabihf/libc_nonshared.a)fstat.oS
/lib/ld-linux-armhf.so.3 
(d:\bbb-toolchain\gnueabihf\bin\../arm-linux-gnueabihf/libc/lib/ld-linux-armhf.so.3)
D:\Software 
Development\MyTesting\BeagleBoneBlack\SQLite\Debug/../sqlite3.c:29970: 
undefined reference to `dlsym'
D:\Software 
Development\MyTesting\BeagleBoneBlack\SQLite\Debug/../sqlite3.c:29970: 
undefined reference to `dlsym'
./sqlite3.o: In function `unixDlClose':
D:\Software 
Development\MyTesting\BeagleBoneBlack\SQLite\Debug/../sqlite3.c:29975: 
undefined reference to `dlclose'

WebRep
Overall rating
 

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to beagleboard+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[beagleboard] Problems installing latest JAVA

2017-01-04 Thread Patrick Ireland
I am trying to install the latest Java on Debian.
I downloaded "jdk-8u111-linux-arm64-vfp-hflt.tar" from Oracle.
I uploaded using FileAilla to BBB to root.
I tried both auto and binary for Filezilla.
I have used Filezilla many times in the past with no problem so it is not 
my candidate for the problem.
BTW, I think FileZilla is an excellent program for transfering files either 
direction with the BBB and Windows 10.

This is the issue I get when I try and tar the file:

root@beaglebone:~# tar xzf jdk-8u111-linux-arm64-vfp-hflt.tar

gzip: stdin: unexpected end of file
tar: Unexpected EOF in archive
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now

I am suspicious that the file may not be valid.
Did I down load the wrong file for the Debian BBB?
Was the download from Oracle corrupt (tried several times)?
Was the upload with FileZilla corrupting (I copied back down from BBB to 
Window 10 and did a successful file match)?
I can only conclude that there is a problem with what file I got from 
Oracle.
Any insight in my error of my procedure will be appreciated.

Thanks,

Pat

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to beagleboard+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/305d3d63-28fa-4c78-a717-43bb227dd26a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[beagleboard] Debian 9.1.0 with VirtualBox unable to "sudo apt-get install crossbuild-essential-armhf"

2017-08-10 Thread Patrick Ireland
I am attempting to install the Debian 9.1.0 system to support 
BeagleBoneBlack on my Windows 10 system.

I am following the Derek Molloy blog site and until I tried to load the 
"sudo apt-get install libicu-dev:armhf", everything was moving smoothly 
(within limits of my Linux knowledge).

http://exploringbeaglebone.com/chapter7/

However, the step to install the libraries fails.

"Some packages could not be installed. This may mean that you have 
requested an impossible situation or if you are using the unstable 
distribution that some required packages have not yet been created or been 
moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
libicu-dev:armhf : Depends : libc6-dev:armhf but it is not going to be 
installed or libc-dev:armhf"

This message leads me to believe that the libicu-dev:armhf is not available 
with Debian 9.1.0 (Stretch).

Am I doing something wrong or is cross library linking not supported on 
Debian 9.1.0 yet?

Assuming that it is not yet supported, any expected date for availability?

Is my only viable solution to reload using Jessie?

TIA,

Pat





-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to beagleboard+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/af7590d6-51ea-4da0-a83b-fca0850d684b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.