Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Syntax & Programs / Re: New guy needs a little help, xport, serial comm. on: April 15, 2009, 10:46:32 am
Can you post your code?

2  Forum 2005-2010 (read only) / Syntax & Programs / Re: New guy needs a little help, xport, serial comm. on: April 12, 2009, 09:41:38 pm
Update, I am pulling values!!

New Code
Code:
#include <NewSoftSerial.h>
#include <AF_XPort.h>
#include <stdio.h>

#define IPADDR "192.168.0.101"
#define HTTPPATH "/bit.txt"

//#define IPADDR "70.40.207.211"  //cnn.com
//#define HTTPPATH "/arduino/bit.txt"

#define PORT 80

#define XPORT_RESETPIN 2  //reset xport
#define XPORT_TXPIN  3    //serial tx
#define XPORT_RXPIN  4    //serial rx
#define XPORT_DTRPIN 5    //internet connection ended signal from xport
#define XPORT_CTSPIN 6    //used by arduino to stop xport overwhelming it with data
#define XPORT_RTSPIN 7    //signal for more data available... not used

char linebuffer[256]; // large buffer for storing data
  
AF_XPort xport = AF_XPort(XPORT_RXPIN, XPORT_TXPIN, XPORT_RESETPIN, XPORT_DTRPIN, XPORT_RTSPIN, XPORT_CTSPIN);

void setup()  
  {
    Serial.begin(19200);
    xport.begin(19200);
    xport.reset();
    delay(1000);
    Serial.println("QueueBot 5000");
    Serial.println("Finished Setup...");
  }

void loop()
{
fetchStuff();
}


char * fetchStuff() {
  uint8_t ret;

  ret = xport.reset();
  Serial.print("Ret: "); Serial.println(ret, HEX);
  switch (ret) {
   case  ERROR_TIMEDOUT: {
      Serial.println("Timed out on reset!");
      return 0;
   }
   case ERROR_BADRESP:  {
      Serial.println("Bad response on reset!");
      return 0;
   }
   case ERROR_NONE: {
    Serial.println("Reset OK!");
    break;
   }
   default:
     Serial.println("Unknown error");
     return 0;
  }
  
  // time to connect...
 
  ret = xport.connect(IPADDR, PORT);
    switch (ret) {
   case  ERROR_TIMEDOUT: {
      Serial.println("Timed out on connect");
      return 0;
   }
   case ERROR_BADRESP:  {
      Serial.println("Failed to connect");
      return 0;
   }
   case ERROR_NONE: {
     Serial.println("Connected..."); break;
   }
   default:
     Serial.println("Unknown error");
     return 0;
  }
  
  // send the HTTP command
 
    xport.print("GET "); xport.println(HTTPPATH);

    ret = xport.readline_timeout(linebuffer, 255, 3000); // 3s timeout
    // if we're using flow control, we can actually dump the line at the same time!
    // Serial.print(linebuffer);
 while(ret!=0)
  {
   Serial.println(linebuffer);  
   ret=xport.readline_timeout(linebuffer,255,1000);
  }
 //Serial.print("Readline returned: ");Serial.println(ret,HEX);
  xport.flush(1000);
}

New Serial Output
Code:
QueueBot 5000
Finished Setup...
Ret: 0
Reset OK!
Connected...
<data>
01000000
</data>
D
Ret: 0
Reset OK!
Failed to connect
Ret: 0
Reset OK!
Failed to connect
Ret: 0
Reset OK!
Failed to connect
Ret: 0
Reset OK!
Connected...
<data>
01000000
</data>
D
Ret: 0
Reset OK!
Failed to connect
Ret: 0
Reset OK!


bit.txt
Code:
<data>
01000000
</data>

Notice how every other fetch it fails to connect, any insight into this behavior?
3  Forum 2005-2010 (read only) / Syntax & Programs / Re: New guy needs a little help, xport, serial comm. on: April 12, 2009, 09:09:55 pm
This is were I am at with this:

Arduino Code:
Code:
#include <NewSoftSerial.h>
#include <AF_XPort.h>
#include <stdio.h>

#define IPADDR "192.168.0.101"
#define HTTPPATH "/bit.txt"

//#define IPADDR "70.40.207.211"  //cnn.com
//#define HTTPPATH "/arduino/bit.txt"

#define PORT 80

#define XPORT_RESETPIN 2  //reset xport
#define XPORT_TXPIN  3    //serial tx
#define XPORT_RXPIN  4    //serial rx
#define XPORT_DTRPIN 5    //internet connection ended signal from xport
#define XPORT_CTSPIN 6    //used by arduino to stop xport overwhelming it with data
#define XPORT_RTSPIN 7    //signal for more data available... not used

char linebuffer[256]; // large buffer for storing data
  
AF_XPort xport = AF_XPort(XPORT_RXPIN, XPORT_TXPIN, XPORT_RESETPIN, XPORT_DTRPIN, XPORT_RTSPIN, XPORT_CTSPIN);

void setup()  
  {
    Serial.begin(19200);
    xport.begin(19200);
    xport.reset();
    delay(1000);
    Serial.println("QueueBot 5000");
    Serial.println("Finished Setup...");
  }

void loop()
{
fetchStuff();
}


char * fetchStuff(void) {
  uint8_t ret;
  char *found=0, *start=0, *end=0;
  

  ret = xport.reset();
  Serial.print("Ret: "); Serial.print(ret, HEX);
  switch (ret) {
   case  ERROR_TIMEDOUT: {
      Serial.println("Timed out on reset!");
      return 0;
   }
   case ERROR_BADRESP:  {
      Serial.println("Bad response on reset!");
      return 0;
   }
   case ERROR_NONE: {
    Serial.println("Reset OK!");
    break;
   }
   default:
     Serial.println("Unknown error");
     return 0;
  }
  
  // time to connect...
 
  ret = xport.connect(IPADDR, PORT);
    switch (ret) {
   case  ERROR_TIMEDOUT: {
      Serial.println("Timed out on connect");
      return 0;
   }
   case ERROR_BADRESP:  {
      Serial.println("Failed to connect");
      return 0;
   }
   case ERROR_NONE: {
     Serial.println("Connected..."); break;
   }
   default:
     Serial.println("Unknown error");
     return 0;
  }
  
  // send the HTTP command, ie "GET /username/"
  
  xport.print("GET "); xport.println(HTTPPATH);


    ret = xport.readline_timeout(linebuffer, 255, 3000); // 3s timeout
    // if we're using flow control, we can actually dump the line at the same time!
    Serial.print(linebuffer);

}

Xport Settings:
Code:
Baudrate (19200) ?
I/F Mode (4C) ?
Flow (02) ?
Port No (10001) ?
ConnectMode (D4) ?
Send '+++' in Modem Mode  (Y) ?
Show IP addr after 'RING'  (Y) ?
Auto increment source port  (N) ?
Remote IP Address : (000) .(000) .(000) .(000)
Remote Port  (0) ?
DisConnMode (00) ?
FlushMode   (33) ?
DisConnTime (00:00) ?:
SendChar 1  (00) ?
SendChar 2  (00) ?

Serial Output / Error:
Code:
QueueBot 5000
Finished Setup...
Ret: 0Reset OK!
Connected...
<data>Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 0Reset OK!
Connected...
<data>Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 3Bad response on reset!
Ret: 0Reset OK!
Connected...
<data>Ret: 3Bad response on reset!
Ret: 3Bad response on reset!


Any ideas?

Thanks!
4  Forum 2005-2010 (read only) / Interfacing / Xport fetch woes !! on: June 16, 2009, 08:44:52 pm
Argh, I have been working on this for days and no one seems to be able to help.  I need to fetch a small amount of data from a webservice.  This fetch includes the headers and a small 7 character string.  I am working on fetching the cookie out of the header right now but the damn device is acting erratic .   I really need help on this, some one please take a look.  Thank you.

Code:

*** Channel 1
Baudrate 9600, I/F Mode 4C, Flow 00
Port 10001
Connect Mode : C5
Send '+++' in Modem Mode enabled
Show IP addr after 'RING' enabled
Auto increment source port disabled
Remote IP Adr: 216.22.xxx.xxx, Port 00080
Disconn Mode : 00
Flush   Mode : 33

Code:
#include <NewSoftSerial.h>
#include <AF_XPort.h>
#include <stdio.h>
#include <avr/io.h>
#include <string.h>

#define cookieLength 256

#define GET_WITH_HEADERS ("GET /community.bizblog.ticketq.TicketQ/ticketQStatus HTTP/1.1\nHost: 172.16.100.200\n\n")      
#define  GET_WITHOUT_HEADERS ("GET /community.bizblog.ticketq.TicketQ/ticketQStatus HTTP/1.1\nHost: 172.16.100.200\nCookie: JSESSIONID=")                          

char linebuffer[256]; // large buffer for storing data

char cookie[cookieLength]; // the cookie
char stringReturn[7];

#define XPORT_RESETPIN 2  //reset xport
#define XPORT_TXPIN  3    //serial tx
#define XPORT_RXPIN  4    //serial rx
#define XPORT_DTRPIN 5    //internet connection ended signal from xport
#define XPORT_CTSPIN 6    //used by arduino to stop xport overwhelming it with data
#define XPORT_RTSPIN 7    //signal for more data available... not used

AF_XPort xport = AF_XPort(XPORT_RXPIN, XPORT_TXPIN, XPORT_RESETPIN, XPORT_DTRPIN, XPORT_RTSPIN, XPORT_CTSPIN);

void setup()  
{
  Serial.begin(9600);
  xport.begin(9600);
  xport.reset();
  delay(1000);
  Serial.println("QueueBot 5000");
  Serial.println("Finished Setup...");
}

char * getCookie()
{
  char *found=0, *start=0, *end=0;
  xport.flush(300);
  
  xport.print(GET_WITH_HEADERS);      

  int numCharsRead = 0;
  int StartChar = 0, endCard=0;

   do
    {
        numCharsRead = xport.readline_timeout( linebuffer, 255, 2000 );  
        found = strstr(linebuffer, "JSESSIONID=");
      if (((int)found) != 0)
      {
        start = strstr(found, "=");
        end = strstr(found, ";");
        if ((start != 0) && (end != 0))
        {
          Serial.println("\n******Found Cookie!*******");
          end[0] = '\0';
          strncpy(cookie, found, 37);
          cookie[cookieLength-1] = 0;
        }
      }  
  } while ( numCharsRead > 0 );
  
 linebuffer[numCharsRead] = '\0';
 return(cookie);
}


void loop()
{
char* cookie = getCookie();
Serial.println("   ** mainLoop ** ");
Serial.print("Cookie: ");
Serial.println(cookie);
}



And here are the results I am getting,

Code:
JSESSIOQueueBot 5000
Finished Setup...

******Found Cookie!*******
   ** mainLoop **
Cookie: JSESSIONID=58306ebc055d9db2748e514065

******Found Cookie!*******
   ** mainLoop **
Cookie: JSESSIONID=583020a35c13beea758a6a1025

******Found Cookie!*******
   ** mainLoop **
Cookie: JSESSIONID=583041b03f5255d3b9c56774a1

******Found Cookie!*******
   ** mainLoop **
Cookie: JSESSIONID=583015dca19bbe36f15726541e

******Found Cookie!*******
   ** mainLoop **
Cookie: JSESSIONID=5830e0096d25a28228146e3037
   ** mainLoop **
Cookie: JSESSIONID=5830e0096d25a28228146e3037
   ** mainLoop **
Cookie: JSESSIONID=5830e0096d25a28228146e3037
   ** mainLoop **
Cookie: JSESSIONID=5830e0096d25a28228146e3037

******Found Cookie!*******
   ** mainLoop **
Cookie: JSESSIONID=5830bf9ccf15676c3c8a275b61
   ** mainLoop **
Cookie: JSESSIONID=5830bf9ccf15676c3c8a275b61

******Found Cookie!*******



You will see it works fine for three of four fetches and then it starts repeating values.  Any help on this would be great, below is an example GET done via telnet of an ideal fetch which I will be parsing.

Code:
Connected to xxxxxxx.xxxxxx.net.
Escape character is '^]'.
GET /community.bizblog.ticketq.TicketQ/ticketQStatus HTTP/1.1
Host: 192.156.6.6

HTTP/1.1 200 OK
Date: Wed, 17 Jun 2009 01:40:46 GMT
Server: Apache
Set-Cookie: JSESSIONID=58308377bb904cd147aa3d3d661968502279;path=/
Connection: close
Transfer-Encoding: chunked
Content-Type: text/plain; charset=UTF-8

6
RoYoGo    [b] <---- This is the string I will be parsing[/b]
0

Connection closed by foreign host.
dyer:~ dyer$


Thanks again for any help you guys can give me !!!!

Regards,

John
5  Forum 2005-2010 (read only) / Interfacing / Xport fetch trouble on: May 11, 2009, 03:52:27 pm
I am not sure why, but I am getting flakey results with an xport direct.  It works one day great, and then the next day it doesnt.  For example now,  I am getting this from my serial output
Code:

QueueBot 5000
Finished Setup...
Getting...
Finished GET

Return value of Data: Æ
error in actOnData func
Getting...
Finished GET

Return value of Data: Æ
error in actOnData func
Getting...
Finished GET

Return value of Data: Æ
error in actOnData func
Getting...
Finished GET

Return value of Data: Æ
error in actOnData func
Getting...
Finished GET

Return value of Data: Æ
error in actOnData func
Getting...
Finished GET

Return value of Data: Æ
error in actOnData func
Getting...
Finished GET

Return value of Data: Æ
error in actOnData func
Getting...
Finished GET

Return value of Data: Æ
error in actOnData func
Getting...
Finished GET

Return value of Data: Æ
error in actOnData func



in my Apache log I see this:

Code:
[Mon May 11 16:48:06 2009] [error] [client 192.168.0.113] Invalid URI in request C192.168.0.101/80\rGET /bit.txt

My fetch function is here

Code:
char * fetchStuff()
  {
    byte ret;
    xport.connect(IPADDR, PORT);
    xport.flush(300);
    Serial.println("Getting...");
    xport.println("GET /bit.txt\n");
      while(xport.serialavail_timeout(300)>0)
        {
          ret=xport.readline_timeout(linebuffer, 255, 1000); // get first line
          //Serial.print("Get Return: ");Serial.print(linebuffer); Serial.print(" -- ");
          Serial.print("Counter: "); Serial.print(counter); Serial.println(" of 10");
          counter++;
        }
  
        Serial.println("Finished GET");
        Serial.println("");
      
        char*      convertedData      = convertData(linebuffer);
        
        //Serial.print("Converted Return: ");Serial.println(convertedData);
        //delay(10000);
        return(convertedData);
    }



  char* convertData(const char* data)
      {
        int len = strlen(data);
        char* myCopy = (char*)malloc( len-1 );
        strcpy( myCopy, data );
        myCopy[len-1] = '\0';
        //int val = strtol(myCopy,0,2); // This returns a value for the string, not in use
        return myCopy;

      }
// End Convert convertData Function

Xport Config
Code:
Baudrate (9600) ?
I/F Mode (4C) ?
Flow (02) ?
Port No (10001) ?
ConnectMode (D4) ?
Send '+++' in Modem Mode  (Y) ?
Show IP addr after 'RING'  (Y) ?
Auto increment source port  (N) ?
Remote IP Address : (000) .(000) .(000) .(000)
Remote Port  (0) ?
DisConnMode (00) ?
FlushMode   (33) ?
DisConnTime (00:00) ?:
SendChar 1  (00) ?
SendChar 2  (00) ?


Any help would be great!!!

Regards,

John
6  Forum 2005-2010 (read only) / Interfacing / Re: XPort Direct+, Arduino Nano, & POST on: April 05, 2009, 11:24:08 am
I am using Ladyada's Xport sheild w/ an Xport Direct+, what options does that leave me with? Thank you also for your quick response!!!

Regards,

John
7  Forum 2005-2010 (read only) / Interfacing / XPort Direct+, Arduino Nano, & POST on: April 05, 2009, 08:54:10 am
So I have been tasked with this project.  Essentially I need a way to posting commands via Ethernet to the Nano. These are not complex commands, literally just actuating pins as needed. However I am having trouble finding examples on how to do this.  Most of the tutorials I find online are for getting data from the Arduino => Web, and I need to do it the other way =)  Any help would be great!!!  

I also wanted to ask if there was any way to server up php from the Xport?

Thank you!


-John
8  Forum 2005-2010 (read only) / Workshops / Re: South Florida Workshop / Group on: May 27, 2009, 10:24:52 am
PM Sent
9  Forum 2005-2010 (read only) / Workshops / Re: South Florida Workshop / Group on: May 11, 2009, 09:09:48 am
I also know that a lot of the user groups in the Orlando area have their meetings at Devry University near Mall at Millenia, perhaps they offer free meeting space?  orug.org has their meetings there every month.

Regards,

John
10  Forum 2005-2010 (read only) / Workshops / Re: South Florida Workshop / Group on: May 11, 2009, 09:07:49 am
I tried to send a PM to user: Producerism but it wouldnt allow me, so I will post it here and hope he gets it.

Code:
They have an orlando Adobe users group, here is the link.

http://adogo.us/

Regards,

John
11  Forum 2005-2010 (read only) / Workshops / Re: South Florida Workshop / Group on: May 11, 2009, 09:02:57 am
Any word on this?  I am in Orlando and would love to get together for a meetup.  I have subscribed to this thread, and I certainly hope to hear some updates shortly!!

Regards,

John

12  Forum 2005-2010 (read only) / Exhibition / Re: send me a message! on: April 05, 2009, 06:34:25 pm
Any updates on this, I am really interested to see how this works!
13  Forum 2005-2010 (read only) / News / New OSX Terminal Emulator! on: May 21, 2009, 12:29:09 pm
I saw this today, pretty nice if you would rather avoid using 'screen' =)

http://www.macupdate.com/info.php/id/31352/coolterm

Enjoy!

Regards,

John
Pages: [1]