converting my project from rpi2

Moderators: mdrjr, odroid

converting my project from rpi2

Unread postby ant17 » Sat Dec 05, 2015 2:22 pm

hi guys i was wondering if you could help me convert my c program designed for raspberri pi 2 below is the code
Code: Select all
#include <stdio.h>
#include <stdlib.h>   // EXIT_SUCCESS
#include <string.h>   // strsignal()
#include <unistd.h>   // getpid()
#include <signal.h>   // signal(), kill()
#include <wiringPi.h>

#define LED1 1
#define LED2 2
#define LED3 3
#define LED4 4
#define LED5 5
#define LED6 6
#define LED7 7
#define LED8 8

#define NUM_SEQUENCES 7
#define NUM_PINS 8
#define CYCLE_DELAY 500
#define RUN_MODE_RUN 0
#define RUN_MODE_STOP -1

/**
 * Control-C Program exit
*/
sig_atomic_t giExitFlag = RUN_MODE_RUN; // will hold the signal which cause exit

static void exitHandler(int sig) {
    giExitFlag = sig;
    fprintf(stderr, "Program Exiting, from signal=%d:%s\n", sig, strsignal(sig));
}

void signalsInit() {
    signal(SIGINT,  exitHandler);  // Ctrl-C
    signal(SIGQUIT, exitHandler);  // Quit
    signal(SIGTERM, exitHandler);  // Normal kill command
}

void signalsCleanup() {
    signal(SIGINT, SIG_DFL);
    signal(SIGQUIT, SIG_DFL);
    signal(SIGTERM, SIG_DFL);

    if (giExitFlag != RUN_MODE_STOP) { // exit caused by some interrupt -- otherwise it would be exactly 0
        kill(getpid(), giExitFlag);
    }
}


int main(int argc, char *argv[])
{
   int seq = 0, pin = 0, index = 0;

   int ledPin[NUM_PINS] = {LED1,LED2,LED3,LED4,LED5,LED6,LED7,LED8};
   int runSets[NUM_SEQUENCES][NUM_PINS] = {
      {1,0,0,1,0,1,0,0},
      {1,0,0,1,0,0,0,1},
      {0,1,1,0,1,0,0,0},
      {0,1,1,0,0,0,1,0},
      {0,0,1,1,1,1,0,0},
      {0,0,1,1,1,0,0,1},
      {0,0,1,1,0,1,1,0}
   };

    /*  consider using wiringPiSetupSys();
    *  no root user required, but pin numbers are different */
   wiringPiSetup();

   signalsInit();

   for (pin = 0; pin < NUM_PINS; pin ++ ) {
     pinMode (ledPin[pin], OUTPUT) ;
   }

   do    {
     
      for (seq = 0; seq < NUM_SEQUENCES; seq++) {
         for (pin = 0; pin < NUM_PINS; pin++) {
            digitalWrite (ledPin[pin], runSets[seq][pin]) ;
         }
         delay(CYCLE_DELAY);  // only delay after a whole set sequence has been handled
      }
     
   } while( giExitFlag == RUN_MODE_RUN );
   
   signalsCleanup();
   
   return EXIT_SUCCESS;
}


if you could help i would be verry greatful
ant17
 
Posts: 54
Joined: Mon Sep 14, 2015 3:31 pm
languages_spoken: english
ODROIDs: odroid xu4

Re: converting my project from rpi2

Unread postby Gobi » Sat Dec 05, 2015 3:52 pm

What errors are the compiler throwing you?
Gobi
 
Posts: 15
Joined: Wed Sep 02, 2015 8:30 pm
languages_spoken: english
ODROIDs: Odroid XU4

Re: converting my project from rpi2

Unread postby ant17 » Sat Dec 05, 2015 4:23 pm

its not when i compile its when i try to run it i get the below message
expecting BCM2708 or BCM2709 if this is a genuine raspberry pi please report to projects@drogon.net
ant17
 
Posts: 54
Joined: Mon Sep 14, 2015 3:31 pm
languages_spoken: english
ODROIDs: odroid xu4

Re: converting my project from rpi2

Unread postby Gobi » Sat Dec 05, 2015 8:01 pm

You need to download the wiringpi version made for odroid boards, this should fix your problem :) http://odroid.com/dokuwiki/doku.php?id=en:c1_tinkering has some info:

2. Get the wiringPi library compatible ODROID-C1

# git clone https://github.com/hardkernel/wiringPi

3. Build the library

# cd wiringPi
# ./build
Gobi
 
Posts: 15
Joined: Wed Sep 02, 2015 8:30 pm
languages_spoken: english
ODROIDs: Odroid XU4

Re: converting my project from rpi2

Unread postby ant17 » Sun Dec 06, 2015 7:54 am

ok thanks so much for that in my metal detetector project i need to be able to adjust the voltages +180v and -1v using a boost a buck conveter depending on the current flow through the sensing coil does anyone have any ideas on how i can do this
ant17
 
Posts: 54
Joined: Mon Sep 14, 2015 3:31 pm
languages_spoken: english
ODROIDs: odroid xu4

Re: converting my project from rpi2

Unread postby ant17 » Mon Dec 07, 2015 9:15 am

hi i tried what you said but when i run the program runs for about second then it goes back to the command prompt where as soon as the code had run once i had it in a infinate loop the the program would just keep running also i am not about how you work out the gpio numbers
ant17
 
Posts: 54
Joined: Mon Sep 14, 2015 3:31 pm
languages_spoken: english
ODROIDs: odroid xu4

Re: converting my project from rpi2

Unread postby odroid » Mon Dec 07, 2015 10:10 am

You might need to keep printing "giExitFlag" to find a root cause.
User avatar
odroid
Site Admin
 
Posts: 24602
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: converting my project from rpi2

Unread postby ant17 » Mon Dec 07, 2015 12:44 pm

i tried that any suggestions
ant17
 
Posts: 54
Joined: Mon Sep 14, 2015 3:31 pm
languages_spoken: english
ODROIDs: odroid xu4

Re: converting my project from rpi2

Unread postby ant17 » Mon Dec 07, 2015 3:53 pm

hi guys can anyone tell me how to loop this program in a continuing loop like a do while loop that is all ways true so it just loops forever when i try i keep getting errors
ant17
 
Posts: 54
Joined: Mon Sep 14, 2015 3:31 pm
languages_spoken: english
ODROIDs: odroid xu4

Re: converting my project from rpi2

Unread postby Tpimp » Mon Dec 07, 2015 4:26 pm

Create a variable to watch for. I'm not sure what language you're using but essentially what you are looking for is an event loop. There are so many ways to accomplish this but you need to find the way that fits your knowledge.

Google and read about Linux programming, event loops, control signals.
Tpimp
 
Posts: 355
Joined: Thu Jul 16, 2015 5:57 am
languages_spoken: english
ODROIDs: U3, C1+, XU4

Re: converting my project from rpi2

Unread postby ant17 » Tue Dec 08, 2015 6:57 am

ok i wil try that and if some other people have suggestions i will appreciate it
ant17
 
Posts: 54
Joined: Mon Sep 14, 2015 3:31 pm
languages_spoken: english
ODROIDs: odroid xu4

Re: converting my project from rpi2

Unread postby tewara@cpm » Wed Sep 20, 2017 12:55 am

I am throwing the same error when I run my program and installed the modified wiringPi as in this forum and the manual.
tewara@cpm
 
Posts: 6
Joined: Wed Sep 20, 2017 12:18 am
languages_spoken: english
ODROIDs: c2
xu4

Re: converting my project from rpi2

Unread postby odroid » Wed Sep 20, 2017 7:58 am

Did you compare the wiringpi pin map?
https://wiki.odroid.com/odroid-xu4/hard ... connectors
User avatar
odroid
Site Admin
 
Posts: 24602
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: converting my project from rpi2

Unread postby tewara@cpm » Wed Sep 20, 2017 9:42 pm

odroid wrote:Did you compare the wiringpi pin map?
https://wiki.odroid.com/odroid-xu4/hard ... connectors

I am able to turn it on and off using bash commands, but my program doesn't even run. so it isn't a hardware thing. I am getting unable to determine hardware I see ODROID XU3 expecting _____(rasPi) I have installed wiringPi from https://github.com/hardkernel/wiringPi
tewara@cpm
 
Posts: 6
Joined: Wed Sep 20, 2017 12:18 am
languages_spoken: english
ODROIDs: c2
xu4

Re: converting my project from rpi2

Unread postby odroid » Thu Sep 21, 2017 9:12 am

Try some simple LED tinkering examples first.
https://wiki.odroid.com/odroid-xu4/appl ... o/wiringpi
User avatar
odroid
Site Admin
 
Posts: 24602
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID


Return to Projects

Who is online

Users browsing this forum: No registered users and 1 guest