OpenCores
URL https://opencores.org/ocsvn/plasma/plasma/trunk

Subversion Repositories plasma

[/] [plasma/] [trunk/] [tools/] [etermip.c] - Diff between revs 401 and 417

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 401 Rev 417
Line 56... Line 56...
#define ETHERNET_DEST         0        //6
#define ETHERNET_DEST         0        //6
#define ETHERNET_SOURCE       6        //6
#define ETHERNET_SOURCE       6        //6
#define ETHERNET_FRAME_TYPE   12       //2      IP=0x0800; ARP=0x0806
#define ETHERNET_FRAME_TYPE   12       //2      IP=0x0800; ARP=0x0806
#define IP_PROTOCOL           23       //1      TCP=0x06;PING=0x01;UDP=0x11
#define IP_PROTOCOL           23       //1      TCP=0x06;PING=0x01;UDP=0x11
#define IP_SOURCE             26       //4
#define IP_SOURCE             26       //4
 
#define PACKET_SIZE           600
 
 
static const unsigned char ethernetAddressNull[] =    {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
static const unsigned char ethernetAddressNull[] =    {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
static const unsigned char ethernetAddressPhantom[] = {0x00, 0x10, 0xdd, 0xce, 0x15, 0xd4};
static const unsigned char ethernetAddressPhantom[] = {0x00, 0x10, 0xdd, 0xce, 0x15, 0xd4};
static const unsigned char ethernetAddressPhantom2[] = {0x00, 0x10, 0xdd, 0xce, 0x15, 0xd5};
static const unsigned char ethernetAddressPhantom2[] = {0x00, 0x10, 0xdd, 0xce, 0x15, 0xd5};
 
 
Line 74... Line 75...
 
 
#ifdef SIMULATE_PLASMA
#ifdef SIMULATE_PLASMA
   extern void *IPFrameGet(int freeCount);
   extern void *IPFrameGet(int freeCount);
   extern int IPProcessEthernetPacket(void *frameIn, int length);
   extern int IPProcessEthernetPacket(void *frameIn, int length);
   extern void IPTick(void);
   extern void IPTick(void);
   extern void IPInit(void (*frameSendFunction)(), unsigned char macAddress[6], char name[6]);
   extern void IPInit(void (*frameSendFunction)(const unsigned char *, int),
 
                      unsigned char macAddress[6], char name[6]);
   extern void HtmlInit(int UseFiles);
   extern void HtmlInit(int UseFiles);
   extern void ConsoleInit(void);
   extern void ConsoleInit(void);
   static void *ethFrame;
   static void *ethFrame;
#endif
#endif
 
 
Line 191... Line 193...
#else
#else
   int rc;
   int rc;
#endif
#endif
   (void)param;
   (void)param;
 
 
   if(EthernetActive == 0)
   if(EthernetActive == 0 || header->len > PACKET_SIZE)
      return;
      return;
   if(pkt_data[ETHERNET_FRAME_TYPE] != 0x08)
   if(pkt_data[ETHERNET_FRAME_TYPE] != 0x08)
      return;  //not IP or ARP
      return;  //not IP or ARP
   if(pkt_data[ETHERNET_FRAME_TYPE+1] != 0x00 &&
   if(pkt_data[ETHERNET_FRAME_TYPE+1] != 0x00 &&
      pkt_data[ETHERNET_FRAME_TYPE+1] != 0x06)
      pkt_data[ETHERNET_FRAME_TYPE+1] != 0x06)
Line 285... Line 287...
long SerialOpen(char *name, long baud)
long SerialOpen(char *name, long baud)
{
{
   DCB dcb;
   DCB dcb;
   COMMTIMEOUTS comm_timeouts;
   COMMTIMEOUTS comm_timeouts;
   BOOL rc;
   BOOL rc;
 
   printf("%s:", name);
   serial_handle = CreateFile(name, GENERIC_READ|GENERIC_WRITE,
   serial_handle = CreateFile(name, GENERIC_READ|GENERIC_WRITE,
      0, NULL, OPEN_EXISTING, 0, NULL);
      0, NULL, OPEN_EXISTING, 0, NULL);
   if(serial_handle == INVALID_HANDLE_VALUE)
   if(serial_handle == INVALID_HANDLE_VALUE)
      printf("Serial Port In Use!\n");
   {
 
      printf("no");
 
      return -1;
 
   }
   rc = SetupComm(serial_handle, 16000, 16000);
   rc = SetupComm(serial_handle, 16000, 16000);
   if(rc == FALSE)
   if(rc == FALSE)
      printf("Serial port already in use!!!\n");
      printf("ERROR1\n");
   rc = GetCommState(serial_handle, &dcb);
   rc = GetCommState(serial_handle, &dcb);
   if(rc == FALSE)
   if(rc == FALSE)
      printf("ERROR2\n");
      printf("ERROR2\n");
   dcb.BaudRate = baud;
   dcb.BaudRate = baud;
   dcb.fBinary = 1;
   dcb.fBinary = 1;
Line 324... Line 330...
   comm_timeouts.WriteTotalTimeoutMultiplier = 0;  //blocking write
   comm_timeouts.WriteTotalTimeoutMultiplier = 0;  //blocking write
   comm_timeouts.WriteTotalTimeoutConstant = 0;
   comm_timeouts.WriteTotalTimeoutConstant = 0;
   rc = SetCommTimeouts(serial_handle, &comm_timeouts);
   rc = SetCommTimeouts(serial_handle, &comm_timeouts);
   if(rc == FALSE)
   if(rc == FALSE)
      printf("ERROR5\n");
      printf("ERROR5\n");
 
   printf("OK");
   return(0);
   return(0);
}
}
 
 
 
 
long SerialRead(unsigned char *data, unsigned long length)
long SerialRead(unsigned char *data, unsigned long length)
Line 382... Line 389...
int main(int argc, char *argv[])
int main(int argc, char *argv[])
{
{
   unsigned int ticksLast = GetTickCount();
   unsigned int ticksLast = GetTickCount();
   int length;
   int length;
   unsigned char buf[80];
   unsigned char buf[80];
 
   int i, rc;
 
   char name[80];
   DWORD count;
   DWORD count;
   unsigned int ticks;
   unsigned int ticks;
   int downloadSkip = 0;
   int downloadSkip = 0;
   (void)argc;
   (void)argc;
   (void)argv;
   (void)argv;
 
   (void)i;
 
   (void)rc;
 
   (void)name;
 
 
   //WinPcapInit();
   //WinPcapInit();
#ifndef SIMULATE_PLASMA
#ifndef SIMULATE_PLASMA
   SerialOpen("COM1", 57600);
   printf("Trying ");
 
   for(i = 1; i < 20; ++i)
 
   {
 
      sprintf(name, "COM%d", i);
 
      rc = SerialOpen(name, 57600);
 
      if(rc == 0)
 
         break;
 
      printf(" ");
 
   }
 
   printf("\n");
   if(argc != 2 || strcmp(argv[1], "none"))
   if(argc != 2 || strcmp(argv[1], "none"))
      SendFile();
      SendFile();
   else
   else
      downloadSkip = 1;
      downloadSkip = 1;
#else
#else

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.