User Tools

Site Tools


prensf2010:goodusbwriter

REPL ANYONE?

//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\\
// NAO                                                                     \\
// 2010                                                                    \\ 
// ------------------------------------------------------------------------\\
// NOTE: Any serial connection to the Arduino must                         \\
//       be turned off before the Arduino is disconnected.                 \\
//       BAD THINGS WILL HAPPEN!!!!                                        \\
// Basic REPL for talking to the VDIP1 USB interface                       \\
// Requires that the TX & RX lines of the VDIP1 are                        \\
// connected to digital pins 2 & 3 on the Arduino (tested with deumilanove)\\
// The VDIP1 draws power for the 5v pin and is grounded to the Arduino.    \\
// In order to maintain the handshake protocol the VDIP1 requires          \\
// the CTS and RTS (pins 9 & 10 on the VDIP1) are tied together.           \\
//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\\

#include <NewSoftSerial.h>

NewSoftSerial usb(2,3);

void setup(){  
  usb.begin(9600);
  Serial.begin(9600);
  Serial.println("{_-:Hello:-_} => IPA to begin");
}
void loop(){
  // Check for new messages from VDIP1
  while(usb.available()){
      Serial.print(usb.read(),BYTE);
  }

  // Wait for input from serial monitor/zterm
  if(Serial.available()){
    
    // Send user input to the VDIP1
    while(Serial.available())
      // Makes sure the keyboard buffer is cleared
      // to ensure the entire command is sent.
      usb.print(Serial.read(), BYTE);
    // Terminate message with a carriage return (0x0D=>13)
    usb.print(13,BYTE);
    
    // Print debug from VDIP1
    while(usb.available()){
      Serial.print(usb.read(),BYTE);
    }
    // New-line for readablity
    Serial.println();
  }
}

The command set is pretty much boiler plate DOS, but since it doesn't communicate new-lines it gets a little ugly. To refresh the prompt, type the command ipa to ensure that the VDIP1 is in the ascii command mode. The other commands I care about are as follows:

  • DIR List the files in the current directory
  • CD Change Directory ⇒ CD dirname
  • OPW Open for write ⇒ OWP filename &opt datetime (32bit)
  • WRF Write to file ⇒ WRF numBytes return then data
  • CLF Close file ⇒ CLF filename
  • RD Read file ⇒ RD filename
  • DLF Delete file ⇒ DLF filename
  • DLD Delete Directory ⇒ DLD dirname
  • MKD Make Directory ⇒ MKD dirname
  • FS Freespace ⇒ FR (If the free space is <4gb it will be returned, -1 otherwise I think)
  • FSE Freespace ⇒ FSE (Returns no matter what)

There are many more, here

prensf2010/goodusbwriter.txt · Last modified: 2010/05/25 16:42 by nels_oscar