Shop OBEX P1 Docs P2 Docs Learn Events
My CommonGround — Parallax Forums

My CommonGround

RsadeikaRsadeika Posts: 3,837
edited 2013-10-20 07:21 in Learn with BlocklyProp
In another thread I had made mention of this, so here I will expand. What I want to do is add access to a Raspberry Pi (RPi) to give the ActivityBot more processing power choices? I thought I would try two different setups, the first one will use a more direct serial approach. The RPi has a GPIO header that has a UART pin out, which will be connected to the p11 and p10 pins on the Activity Board with appropriate ground and power connections. The second method will be a straight forward connection using the USB cable from the Activity board to the USB socket on the RPi.

Below is some simple code that sort of works, but does not give me what I am expecting. In this setup the RPi starts up in a login procedure, and in my little program I was trying to create an automatic login with no success. It shows most of the RPi startup information, and it just rolls through the login and password to end up with a blank screen, I was expecting to see the RPi prompt at this point.

What I am trying to accomplish is having the SimpleIDE terminal screen act like a terminal program, basically auto login and then be able to type in commands to use the RPi. Then probably this would be a cog program in the ActivityBot program which would allow things like making use of the time() function that is already running on the RPi, just to name one item. You could use this cog to make use of all kinds of programs that the RPi has avaiable, in a background job situation.

Thanks

Ray

/*
  cg_test1.c
 
*/
#include "simpletools.h"
#include "simpletext.h"
#include "fdserial.h"

serial *rpi; 

int main()
{
  // Add startup code here.
/*                 RPiTx RPiRx  */
/*                    Rx  Tx mode BAUD */
  rpi = fdserial_open(11, 10, 0, 115200);
  char getBuff[80];
 
  while(1)
  {
    // Add main loop code here.
    readStr(rpi,getBuff,80);
    if(strcmp(getBuff,"raspberrypi login:"))
    {
      writeLine(rpi,"pi");
    }
    else if(strcmp(getBuff,"password:"))
    {
      writeLine(rpi,"raspberry");
    }
    else
    { 
      putLine(getBuff);
    }
  }  
}

Comments

  • jazzedjazzed Posts: 11,803
    edited 2013-10-18 09:33
    Function strcmp() returns 0 if there is a match.

    http://linux.die.net/man/3/strcmp
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-10-19 06:18
    I decided to give up on plan 1, and spend some time with plan 2, which is plugging the AB USB cable into the RPi USB socket. I have a small python comm program, and for test purposes I am trying to turn on/off the p26 LED on the AB. The below program works when I use the 'inchar = getChar();' code segment. But when I try to use the ' getStr(getBuff,80);' code segment, I get no response from the AB. I am not sure I understand what exactly getStr() needs for input. On the Py side I just type in 'n' and hit CR.

    Ray

    #include "simpletools.h"
    #include "simpletext.h"
    #include "fdserial.h"
    
    serial * rpi; 
    
    int main()
    {
      // Add startup code here.
    /*                    Rx  Tx mode BAUD */
    //  rpi = fdserial_open(11, 10, 0, 115200);
    
      char getBuff[80];
      char inBuff[80];
      int inchar;
    
      print("Control from RPi\n"); 
      while(1)
      {
        // Add main loop code here.
        getStr(getBuff,80);
        if(strcmp(getBuff,"n") == 0)
        {
          high(26);
        }
        if(strcmp(getBuff,"o") == 0)
        {
          low(26);
        }
    /*    inchar = getChar();
        if(inchar == 'n')
        {
          high(26);
        }
        if(inchar == 'o')
        {
          low(26);
        } */
        pause(200);    
      }
    
      return 0;
    }
    
    
  • jazzedjazzed Posts: 11,803
    edited 2013-10-19 16:31
    Ray,

    Function getStr(char *buff, int max) should read serial data from the default Propeller serial port until max characters, CR (13), or NL (10) are detected.
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-10-20 07:21
    Well, I have playing around with this, and I find this whole setup very cumbersome, to say the least. You have to worry about two different boards not having any problems, let alone programming them. I think the solution has to be an Activity Board with a Propeller that has the capabilities of an ARM processor, something like what is on the RPi, then I think we can get into Parallax robotics in a big way.

    For now I think I will shelf this project, and let the RPi go its separate way, while I work on a minimalist ActivityBot platform. Maybe I will rethink my idea of having some swarming ActivityBot activity, try to distribute the processing power over a couple of bots.

    Ray
Sign In or Register to comment.