Pages: [1]   Go Down
Author Topic: Redirecting serial port to PC via RedFly WiFi shield  (Read 1134 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey guys,

I have a couple of Arduinos in different projects and I would like to be able to update them without unplugging them from their locations and bring them to my PC to upload new sketches.
For that reason, I want to be able to use one of my Arduino Unos with a RedFly WiFi shield from Watterott to proxy the data for me: the "master" Uno with the WiFi shield is connected to the "slaves" Arduinos FTDI (or ISP) header.

Now I would like to just click on upload in the Arduino IDE and have the data be sent to the master via WiFi which will send the data straight to the slave and program it via FTDI.

For that I want to use "socat" (I'm using linux) to create a fake serial port that sends everything to the ip & port of my master, but I can't seem to get that to work at all. I would be happy for now if I could even get avrdude to talk to my master using -Pnet:192.68.0.178:19999, but it only tells me that it times out after it connected.

I'm struggling to understand how the sketch on the master would have to look like. So far I used a simple sketch: read WiFi -> send on Serial (RX/TX connected to FTDI), read on Serial -> write on WiFi. But that apparently isn't enough. I also tried running the BitLash telnet example but had no success as well (I rewrote it to work(?) with the RedFly lib, which is very similar to the Ethernet lib).

So does anyone have tips for me how I could get this running? I already tried googling all over the place for 3 days now, but wasn't able to find something that worked.

Thanks!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, I think I've gotten closer to it. Maybe somebody can tell me, why the Arduino that I'm trying to program doesn't reply at all.

I connected TX/RX on the "master" to RX/TX on the "slave", ground +5V obvious, CTS to ground and DTR to digital pin 4.

Here's my code:
Code:
#include <RedFly.h>
uint8_t serversock, sock;

void setup()
{
  // virtual reset pin
  pinMode(4, OUTPUT); // reset pin for arduino / DTR on FTDI header
  digitalWrite(4, HIGH);

  //init the WiFi module on the shield
  /* wlan init is irrelevant => removed */
}

uint8_t buf[200];
int bp = 0;
bool resetDone = false;

void loop()
{
  /* read data from WiFi to buf - removed for easier read */
 
  RedFly.disable(); // disable WiFi card
  Serial.begin(115200); // change baudrate to Arduino bootloader baudrate

  // buffer pos != 0 -> data received   
  if (bp != 0)
  {
    if (!resetDone)
    {
      // reset slave before sending first data
      digitalWrite(4, LOW);
      delay(200);
      digitalWrite(4, HIGH);
      resetDone = true;
    }
   
    // print received buffer to boatloader
    for (int i = 0; i < bp; i++)
      Serial.print(buf[i], BYTE);
   
    bp = 0;
    // wait a bit for a reply
    delay(100);

    // read reply from bootloader
    while (Serial.available())
      buf[bp++] = Serial.read();
  }

  // change serial back to WiFi cards speed 
  Serial.begin(9600);

  // enable wifi card
  RedFly.enable();

  // we received data from bootloader -> send it via WiFi
  if (bp != 0)
    RedFly.socketSend(sock, buf, bp);
   
  // wait a bit for a reply
  delay(100);
}

The data from WiFi (the first bytes from avrdude, namely 30 20) gets received and redirected at the right baudrate, I checked that. But the bootloader does not respond.

What am I doing wrong?

Thx for any help!

PS:
Code:

~ $ avrdude -C/usr/share/arduino/hardware/tools/avrdude.conf -q -q -patmega328p -carduino -Pnet:192.168.0.178:19999 -b115200 -D -Uflash:w:wlanprog.cpp.hex:i -vvvv

avrdude: Version 5.10, compiled on Jun 29 2010 at 21:09:48
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/usr/share/arduino/hardware/tools/avrdude.conf"
         User configuration file is "/home/emmo/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : net:192.168.0.178:19999
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
ioctl("TIOCMGET"): Invalid argument
ioctl("TIOCMGET"): Invalid argument
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
ioctl("TIOCMGET"): Invalid argument

PPS:
Master = Arduino Uno w/ RedFly shield
Slave = Arduino Ethernet
« Last Edit: September 09, 2011, 06:52:32 pm by Emmeran » Logged

Germany
Offline Offline
Full Member
***
Karma: 8
Posts: 117
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I think a problem is the different serial format (RedFly 8N2, bootloader 8N1).
The best would be to use a software serial port for the RedFly communication or an Arduino Mega with more hardware serial ports.

Regards
Andreas
Logged

Pages: [1]   Go Up
Jump to: