[Coco] Serial to Ethernet

Chris Ahrendt chrisahrendt at bellsouth.net
Tue Feb 10 20:20:02 EST 2015


I actually have a better idea that I floated back about 8 months ago...

Just need the following:

Cart interface.... which I think was being sold on ebay... or even make 
a Y adapter so you can plug in the disk adapter.  the other side plugs 
into an arduino (Yun or regular with either a wired ethernet or the 
wireless adapter.)

Then the following sketch:

#include <SPI.h>
#include <Ethernet.h>

// The network port on which to listen for incoming connections.
int network_port = 5331;

// The baud rate to use for serial communication.  This needs to match the
// speed used by the microcontroller (e.g. the value passed to
// Serial.begin() in an Arduino sketch).
// The communication protocol shall follow the RS-232 standard of 8-N-1
// (1 start bit, 8 data bits, and 1 stop bit).
// By default the Arduino uses 8n1 so we dont have to set anything but 
the baud rate
// For the Color Computer 2, the supported clock
// speed shall is .89MHz and the bit rate is 57,600 bits per second. For the
// Tandy Color Computer 3, the supported clock speed is 1.78MHz and the bit
// rate is 115,200 bits per second
// int serial_baud_rate = 115,200; for the coco 3
int serial_baud_rate = 57600;

byte OP_INIT = 0x49;
byte OP_TERM = 0x54;
byte OP_RESET1 = 0xFE;
byte OP_RESET2 = 0xFF;
byte OP_NOP = 0x00;

// Whether or not to print data coming from the serial port in Processing.
boolean print_in_processing = true;

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
   0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

IPAddress svr1(1,1,1,1);

EthernetClient client;

void setup()
{
   // start the Ethernet connection:
   Ethernet.begin(mac);

   Serial.begin(serial_baud_rate);
   while (!Serial) {
     ; // wait for serial port to connect
   }
   establishContact();  // send a byte to establish contact until 
receiver responds
   client.connect(svr1, network_port);
}

void loop()
{

   // as long as there are bytes in the serial queue,
   // read them and send them out the socket if it's open:
   while (Serial.available() > 0) {
     char inChar = Serial.read();
     if (client.connected()) {
       client.print(inChar);
     }
   }

   // if there are incoming bytes available
   // from the server, read them and print them:
   if (client.available()) {
     char c = client.read();
     Serial.print(c);
   }

   // if the server's disconnected, stop the client:
   if (!client.connected()) {
     Serial.println((char)OP_TERM);
   }
}

void establishContact() {
   while (Serial.available() <= 0) {
     Serial.print((char)OP_NOP);   // send a OP_NOP
     delay(300);
   }
}

  to run on the arduino....

Then the hbdos driver would need to be modified to write to the bus 
instead of the serial port....

Chris



More information about the Coco mailing list