gnupic: XWisp2 with gcc patch


Previous by date: 12 Sep 2005 22:17:35 +0100 Re: [gnupic] code directive question, Bill Freeman
Next by date: 12 Sep 2005 22:17:35 +0100 Re: [gnupic] XWisp2 with gcc patch, Chen Xiao Fan
Previous in thread:
Next in thread:

Subject: XWisp2 with gcc patch
From: Daniel Serpell ####@####.####
Date: 12 Sep 2005 22:17:35 +0100
Message-Id: <20050912211644.GC7925@aplik.cl>

Hi!

El Sat, Sep 10, 2005 at 01:27:58PM +0200, Rob Hamerling escribio:
> 
> Today I have released XWisp2 version 1.7.00.
> Major enhancement: runs now also under Linux besides OS/2 eComStation 
> and Windows.
> 
> See my site, esp. http://www.robh.nl/picsoft.html#xwisp2

Attached, you will find 2 patches:

xwisp2.170.linux.patch :
        This adds a linux "Makefile", and adds various tweaks to the
        sources (like changing includes to lowercase and defining
        some missing functions), so the code compiles under gcc in
        linux.

xwisp2.170.linux.unwarn.patch :
        This fixes some of the warnings on the code. This is not
        complete, and some of the casts are really important if you
        want xwisp2 to work under 64bit arches.

Instructions:
 * Unzip the archive *in lowercase*:
        unzip -L xwisp2170s.zip
 * Patch the sources:
        patch -p1 < xwisp2.170.linux.patch 
        patch -p1 < xwisp2.170.linux.unwarn.patch 
 * Compile with "make":
        make


Hope it helps,

        Daniel.


diff --new-file -ru orig/Makefile linux/Makefile
--- orig/Makefile	1969-12-31 21:00:00.000000000 -0300
+++ linux/Makefile	2005-09-12 17:12:41.000000000 -0400
@@ -0,0 +1,53 @@
+# ----------------------------------------------------------
+# Makefile for xwisp2u and xwlistu for Linux
+# (c) Daniel Serpell
+# ----------------------------------------------------------
+
+CC = gcc
+CFLAGS = -Wall -O2 -Wno-pointer-sign
+HEADERS = xwisp2.h
+OBJECTS = \
+	xwisp2bus.o  \
+	xwisp2cfg.o  \
+	xwisp2cmd.o  \
+	xwisp2com.o  \
+	xwisp2dat.o  \
+	xwisp2hex.o  \
+	xwisp2mis.o  \
+	xwisp2tgt.o  \
+	xwisp2os.o
+TARGETS = xwisp2u xwlistu
+SOURCES = $(OBJECTS:.o=.c)
+
+all: xwisp2u xwlistu
+
+clean:
+	-rm -f $(OBJECTS)
+	-rm -f $(TARGETS)
+	-rm -f xwisp2.o xwlist.o xwisp2cfg.o xwisp2dat.o 
+
+.c.o:
+	@echo "Compiling $<"
+	@$(CC) $(CFLAGS) -c -o $@  $<
+
+xwisp2u: xwisp2.o $(OBJECTS)
+	@echo "Linking $@"
+	@$(CC) xwisp2.o $(OBJECTS) -o $@
+
+xwlistu: xwlist.o xwisp2cfg.o xwisp2dat.o
+	@echo "Linking $@"
+	@$(CC) $^ -o $@
+
+# Automatically generated
+xwisp2bus.o: xwisp2bus.c xwisp2.h compiler.h
+xwisp2.o: xwisp2.c xwisp2.h compiler.h
+xwisp2cfg.o: xwisp2cfg.c xwisp2.h compiler.h
+xwisp2cmd.o: xwisp2cmd.c xwisp2.h compiler.h
+xwisp2com.o: xwisp2com.c xwisp2.h compiler.h
+xwisp2dat.o: xwisp2dat.c xwisp2.h compiler.h
+xwisp2hex.o: xwisp2hex.c xwisp2.h compiler.h
+xwisp2mis.o: xwisp2mis.c xwisp2.h compiler.h
+xwisp2os.o: xwisp2os.c xwisp2.h compiler.h
+xwisp2tgt.o: xwisp2tgt.c xwisp2.h compiler.h
+xwlist.o: xwlist.c xwisp2.h compiler.h
+
diff --new-file -ru orig/xwisp2.c linux/xwisp2.c
--- orig/xwisp2.c	2005-09-08 09:31:36.000000000 -0400
+++ linux/xwisp2.c	2005-09-12 16:56:34.000000000 -0400
@@ -42,7 +42,7 @@
 
 // #define __DEBUG__
 
-#include "XWisp2.h"                             // all includes
+#include "xwisp2.h"                             // all includes
 
 
 // =========================================
diff --new-file -ru orig/xwisp2.h linux/xwisp2.h
--- orig/xwisp2.h	2005-09-09 11:18:28.000000000 -0400
+++ linux/xwisp2.h	2005-09-12 17:09:47.000000000 -0400
@@ -41,7 +41,7 @@
 // compiler includes
 // (not all needed by all modules, but collected here for simplicity)
 
-#if !defined(__LINUX__)
+#if !defined(__LINUX__) && !defined(__linux)
   #include <io.h>                               // gives conflicts
                                                 // with Open Watcom C
                                                 // ignore missing functions!
@@ -53,8 +53,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys\types.h>
-#include <sys\stat.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <time.h>
 
 
@@ -75,13 +75,20 @@
   #define ucDIRECTORYSEPARATOR   '\\'
   #define szDIRECTORYSEPARATOR   "\\"
 
-#elif defined(__LINUX__)                                // Linux
+#elif defined(__LINUX__) || defined(__linux)            // Linux
+  #define __LINUX__
   typedef ULONG  BOOLEAN;
   typedef ULONG  HSERIALPORT;                           // handle for I/O
   #define INVALIDSERIALHANDLE  MINUS1
   #define ucDIRECTORYSEPARATOR   '/'
   #define szDIRECTORYSEPARATOR   "/"
-
+  #define strnicmp strncasecmp
+  #define stricmp strcasecmp
+  #include <ctype.h>
+  #define strupr(a) ({char *_iv=(a),*_r=_iv; while(*_iv) *_iv = toupper(*_iv++);_r; })
+  #define max(a,b) ((a)>(b)?(a):(b))
+  #define min(a,b) ((a)<(b)?(a):(b))
+  #define _searchenv(a,b,c) (*c=0)
 #endif
 
 
diff --new-file -ru orig/xwisp2os.c linux/xwisp2os.c
--- orig/xwisp2os.c	2005-09-08 19:22:16.000000000 -0400
+++ linux/xwisp2os.c	2005-09-12 17:11:30.000000000 -0400
@@ -52,7 +52,7 @@
 
 // #define __DEBUG__
 
-#include "XWisp2.h"                                     // common includes
+#include "xwisp2.h"                                     // common includes
 
 #if defined(__EMX__) && !defined(__OS2__)               // EMX/GCC environment
   #define __OS2__                                       // implies OS/2
@@ -74,10 +74,10 @@
 
 #elif defined(__LINUX__)                                // Linux target
 
-  #include <i86.h>
   #include <termios.h>
   #include <sys/ioctl.h>
   #include <sys/time.h>
+  #include <unistd.h>
 
 #endif
 
diff --new-file -ru orig/xwlist.c linux/xwlist.c
--- orig/xwlist.c	2005-08-25 12:17:18.000000000 -0400
+++ linux/xwlist.c	2005-09-12 16:56:34.000000000 -0400
@@ -9,7 +9,7 @@
 //
 // ------------------------------------------------------------------------
 
-#include "XWisp2.h"                             // all common headers
+#include "xwisp2.h"                             // all common headers
 
 // ---------------------------------------------
 extern int main(int args, char *argv[]) {

diff --new-file -ru linux/xwisp2bus.c linux-2/xwisp2bus.c
--- linux/xwisp2bus.c	2005-09-12 16:56:30.000000000 -0400
+++ linux-2/xwisp2bus.c	2005-09-12 16:28:13.000000000 -0400
@@ -69,7 +69,7 @@
   szBuffer[i] = '\0';                                   // end of string
   rc = SendReceive(szBuffer, szReply);
   if (rc) {
-    sprintf(szBuffer, "WbusNext failed, rc %lu", rc);
+    sprintf(szBuffer, "WbusNext failed, rc %lu", (unsigned long)rc);
     LogMsg(szBuffer);
     return  rc;
     }
@@ -83,7 +83,7 @@
     for (  ; i<ulBufSize-1; ++i) {                      // rest of reply
       rc = SendReceiveSlow("n", szReply + i);           // byte-by-byte
       if (rc != XW_NOERROR) {                           // problem
-        sprintf(szBuffer, "WbusNext failed, rc %lu", rc);
+        sprintf(szBuffer, "WbusNext failed, rc %lu", (unsigned long)rc);
         LogMsg(szBuffer);
         break;
         }
@@ -110,7 +110,7 @@
   LogMsg("WbusGo()");
   rc = SendReceive("0000g", ucReply);
   if (rc) {
-    sprintf(szBuffer, "WbusGo failed, rc %lu", rc);
+    sprintf(szBuffer, "WbusGo failed, rc %lu", (unsigned long)rc);
     LogMsg(szBuffer);
     }
   return rc;
@@ -135,7 +135,7 @@
 
   rc = SendReceiveSlow("a", szReply);                   // to check echo
   if (rc != XW_NOERROR) {                               // problem
-    sprintf(szBuffer, "Communications error, rc %lu", rc);
+    sprintf(szBuffer, "Communications error, rc %lu", (unsigned long)rc);
     return rc;
     }
   if (strlen(szReply) == 1  &&  szReply[0] == 'A')
@@ -159,7 +159,7 @@
   rc = SendReceiveSlow("0000h", szReply);               // byte-by-byte
   if (rc != XW_NOERROR  ||  strcmp(szReply, "0000H")) {  // problem
     if (rc != XW_NOERROR)
-      sprintf(szBuffer, "WbusHello failed, rc %lu", rc);
+      sprintf(szBuffer, "WbusHello failed, rc %lu", (unsigned long)rc);
     else
       sprintf(szBuffer, "WbusHello failed, %s (received: %s)",
                         (ulWbusBaudrateActual != DEFBAUDRATE)
@@ -188,7 +188,7 @@
   LogMsg("WbusIncrement()");
   rc = SendReceiveSlow("i", szReply);                   // single byte
   if (rc) {
-    sprintf(szBuffer, "WbusIncrement failed, rc %lu", rc);
+    sprintf(szBuffer, "WbusIncrement failed, rc %lu", (unsigned long)rc);
     LogMsg(szBuffer);
     return rc;
     }
@@ -217,7 +217,7 @@
                     (pTUsed->Family == CORE_16) ? ulLocation : ulLocation/2);
   rc = SendReceive(szBuffer, szReply);                  // burst preferred
   if (rc) {
-    sprintf(szBuffer, "WbusJump failed, rc %lu", rc);
+    sprintf(szBuffer, "WbusJump failed, rc %lu", (unsigned long)rc);
     LogMsg(szBuffer);
     return rc;
     }
@@ -261,7 +261,7 @@
     sprintf(szBuffer, "%04hx", usPassCfg);              // 'p' parameters
     rc = SendReceive(szBuffer, szReply);                // first part
     if (rc) {
-      sprintf(szBuffer, "PassThrough failed, rc %lu", rc);
+      sprintf(szBuffer, "PassThrough failed, rc %lu", (unsigned long)rc);
       LogMsg(szBuffer);
       return rc;
       }
@@ -272,7 +272,7 @@
 //  rc = SendReceive(szBuffer, szReply);                // whole command
 //  }
   if (rc) {
-    sprintf(szBuffer, "PassThrough failed, rc %lu", rc);
+    sprintf(szBuffer, "PassThrough failed, rc %lu", (unsigned long)rc);
     LogMsg(szBuffer);
     return rc;
    }
@@ -321,7 +321,7 @@
                      usMemType);
   rc = SendReceive(szBuffer, szReply);                  // burst preferred
   if (rc) {
-    sprintf(szBuffer, "WbusProgram failed, rc %lu", rc);
+    sprintf(szBuffer, "WbusProgram failed, rc %lu", (unsigned long)rc);
     LogMsg(szBuffer);
     return rc;
     }
@@ -357,12 +357,12 @@
 
   rc = SendReceiveSlow("r", szReply);                   // single byte!
   if (rc) {
-    sprintf(szBuffer, "WbusRead failed, rc %lu", rc);
+    sprintf(szBuffer, "WbusRead failed, rc %lu", (unsigned long)rc);
     LogMsg(szBuffer);
     return rc;
     }
   rc = SolicitReply(szReplyBuffer, ulReplySize, ulBufSize);   // obtain reply
-  sprintf(szBuffer, "WbusRead(%06x : %s)",
+  sprintf(szBuffer, "WbusRead(%06lx : %s)",
                      ulLastAddress,
                      (rc == XW_NOERROR) ? szReplyBuffer : szNoReply);
   LogMsg(szBuffer);
@@ -394,11 +394,11 @@
 
   rc = SendReceiveSlow("t", szReply);                   // single byte
   if (rc)
-    printf("WbusType() failed, rc %lu\n", rc);
+    printf("WbusType() failed, rc %lu\n", (unsigned long)rc);
   else {
     rc = SolicitReply(szBuffer, 0, sizeof(szBuffer));   // obtain string
     if (rc)
-      printf("WBus device name not received, rc %lu\n", rc);
+      printf("WBus device name not received, rc %lu\n", (unsigned long)rc);
     else {
       strncpy(szDevice, szBuffer, sizeof(szDevice)-1);
       szDevice[sizeof(szDevice)-1] = '\0';              // zero termination
@@ -433,11 +433,11 @@
   ulMajor = ulMinor = 0;                                // for default reply
   rc = SendReceiveSlow("v", szReply);                   // single byte
   if (rc)                                               // problem
-    printf("WbusVersion() failed, rc %lu\n", rc);
+    printf("WbusVersion() failed, rc %lu\n", (unsigned long)rc);
   else {
     rc = SolicitReply(szBuffer, 4, sizeof(szBuffer));   // obtain reply
     if (rc)
-      printf("Firmware version not received, rc %lu\n", rc);
+      printf("Firmware version not received, rc %lu\n", (unsigned long)rc);
     else {
       s = strtok(szBuffer, ".");                        // probably Wisp628
       if (s != NULL) {
@@ -452,7 +452,7 @@
         }
       }
     }
-  sprintf(szBuffer, "WbusVersion(%u.%02u)", ulMajor, ulMinor);
+  sprintf(szBuffer, "WbusVersion(%lu.%02lu)", ulMajor, ulMinor);
   LogMsg(szBuffer);
   return  100 * ulMajor + ulMinor;                      // firmware level
   }
@@ -488,7 +488,7 @@
   if (rc) {                                             // problem
     sprintf(szBuffer, "Wbus%sWrite failed, rc %lu",
                        (bLazyWrite) ? "Lazy" : "",
-                       rc);
+                       (unsigned long)rc);
     LogMsg(szBuffer);
     return rc;
     }
diff --new-file -ru linux/xwisp2.c linux-2/xwisp2.c
--- linux/xwisp2.c	2005-09-12 16:56:34.000000000 -0400
+++ linux-2/xwisp2.c	2005-09-12 16:17:31.000000000 -0400
@@ -56,7 +56,7 @@
 //  - shutdown
 //
 // =========================================
-extern int main(int argc, unsigned char **argv) {
+extern int main(int argc, char **argv) {
 
   ULONG  rc;                                         // returncode
   ULONG  ulProgramStartTime;                         // start of run
diff --new-file -ru linux/xwisp2cfg.c linux-2/xwisp2cfg.c
--- linux/xwisp2cfg.c	2005-09-12 16:56:30.000000000 -0400
+++ linux-2/xwisp2cfg.c	2005-09-12 16:37:33.000000000 -0400
@@ -446,7 +446,7 @@
   pKwdFile = fopen(szKeywordFile, "r");                 // open file
   if (pKwdFile == NULL) {                               // error
     printf("ERR: Could not open PIC configuration file '%s'\n, errno=%lu",
-            szKeywordFile, errno);                      // file not found(?)
+            szKeywordFile, (unsigned long)errno);       // file not found(?)
     return errno;
     }
 
@@ -937,7 +937,7 @@
   pCfgFile = fopen(szBuffer, "r");                      // try to open
   if (pCfgFile == NULL) {
     printf("ERR: Could not open base PIC configuration file '%s', errno=%lu\n",
-            szBuffer, errno);                           // file not found(?)
+            szBuffer, (unsigned long)errno);            // file not found(?)
     return errno;
     }
 
Binary files linux/.xwisp2os.c.swp and linux-2/.xwisp2os.c.swp differ

Previous by date: 12 Sep 2005 22:17:35 +0100 Re: [gnupic] code directive question, Bill Freeman
Next by date: 12 Sep 2005 22:17:35 +0100 Re: [gnupic] XWisp2 with gcc patch, Chen Xiao Fan
Previous in thread:
Next in thread:


Powered by ezmlm-browse 0.20.