View | Details | Raw Unified | Return to bug 83174
Collapse All | Expand All

(-)devel/picprog/Makefile (+1 lines)
Lines 7-12 Link Here
7
7
8
PORTNAME=	picprog
8
PORTNAME=	picprog
9
PORTVERSION=	1.7
9
PORTVERSION=	1.7
10
PORTREVISION=	1
10
CATEGORIES=	devel
11
CATEGORIES=	devel
11
MASTER_SITES=	http://hyvatti.iki.fi/~jaakko/pic/
12
MASTER_SITES=	http://hyvatti.iki.fi/~jaakko/pic/
12
13
(-)devel/picprog/files/patch-main.cc (-4 / +43 lines)
Lines 1-10 Link Here
1
--- main.cc.orig	Tue Nov 19 12:50:51 2002
1
--- main.cc.orig	Thu Apr 29 00:41:25 2004
2
+++ main.cc	Tue Nov 19 12:51:11 2002
2
+++ main.cc	Fri Jul  8 22:02:29 2005
3
@@ -32,6 +32,7 @@
3
@@ -31,6 +31,7 @@
4
 
4
 
5
 #include <sysexits.h>
5
 #include <sysexits.h>
6
 #include <unistd.h>
6
 #include <unistd.h>
7
+#define HAVE_DECL_GETOPT 1
7
+#define HAVE_DECL_GETOPT 1
8
 #include <getopt.h>
8
 #include <getopt.h>
9
 #include <string.h>
9
 
10
 
10
 #include "hexfile.h"
11
@@ -41,7 +42,7 @@
12
 
13
 program prog;
14
 
15
-char short_opts [] = "d:p:i:o:c:qh?";
16
+char short_opts [] = "d:p:i:o:c:qsh?";
17
 
18
 int
19
 main (int argc, char **argv)
20
@@ -52,7 +53,7 @@
21
   int opt_usage = 0;
22
 
23
   int opt_format = hexfile::unknown;
24
-  char *opt_port = (char *)"/dev/ttyS0";
25
+  char *opt_port = (char *)"/dev/cuaa0";
26
   char *opt_input = NULL;
27
   char *opt_output = NULL;
28
   char *opt_cc = NULL;
29
@@ -81,6 +82,7 @@
30
     {"erase", no_argument, &opt_erase, 1},
31
     {"burn", no_argument, &opt_burn, 1},
32
     {"force-calibration", no_argument, &opt_calibration, 1},
33
+    {"slow", no_argument, NULL, 's'},
34
     {0, 0, 0, 0}
35
   };
36
 
37
@@ -113,6 +115,12 @@
38
     case 'q':
39
       opt_quiet = 1;
40
       break;
41
+    case 's':
42
+	// Add extra delays for capacity added by very long cable
43
+	picport::t_edge = 10; // 10 us
44
+	picport::t_on = 200000;  // 200 ms
45
+	picport::t_off = 700000; // 700 ms - I'm not kidding !
46
+	break;
47
     default: // -? -h --help unknown flag
48
       opt_usage = 1;
49
     }
(-)devel/picprog/files/patch-picport.cc (-2 / +80 lines)
Lines 1-5 Link Here
1
--- picport.cc.orig	Thu Apr 29 06:08:10 2004
1
--- picport.cc.orig	Thu Apr 29 00:08:10 2004
2
+++ picport.cc	Wed May 25 11:09:06 2005
2
+++ picport.cc	Fri Jul  8 21:46:07 2005
3
@@ -40,7 +40,7 @@
3
@@ -40,7 +40,7 @@
4
 #include <unistd.h>
4
 #include <unistd.h>
5
 #include <termios.h>
5
 #include <termios.h>
Lines 9-11 Link Here
9
 #include <sched.h>
9
 #include <sched.h>
10
 
10
 
11
 #include "picport.h"
11
 #include "picport.h"
12
@@ -54,6 +54,11 @@
13
 unsigned int picport::tsc_1000ns = 0;
14
 int picport::use_nanosleep = -1;
15
 
16
+// Extra delays for long cables, in us
17
+int picport::t_on = 0;
18
+int picport::t_off = 0;
19
+int picport::t_edge = 0;
20
+
21
 void
22
 picport::set_clock_data (int rts, int dtr)
23
 {
24
@@ -102,7 +107,7 @@
25
   // Before first call to set_clock_data, read the modem status.
26
   ioctl (fd, TIOCMGET, &modembits);
27
   set_clock_data (0, 0);
28
-  usleep (50);
29
+  usleep (50+t_edge);
30
   // Check the CTS.  If it is up, even when we just lowered DTR,
31
   // we probably are not talking to a JDM type programmer.
32
   int i;
33
@@ -200,13 +205,13 @@
34
     cerr << "Unable to start break on tty " << tty << ":" << strerror (e) << endl;
35
     exit (EX_IOERR);
36
   }
37
-  usleep (10);
38
+  usleep (10+t_off);
39
 }
40
 
41
 picport::~picport ()
42
 {
43
   ioctl (fd, TIOCCBRK, 0);
44
-  usleep (1);
45
+  usleep (1+t_off);
46
   tcsetattr (fd, TCSANOW, &saved);
47
   close (fd);
48
   delete [] portname;
49
@@ -216,15 +221,15 @@
50
 {
51
   set_clock_data (0, 0);
52
   ioctl (fd, TIOCCBRK, 0);
53
-  usleep (50);
54
+  usleep (50+t_off);
55
   ioctl (fd, TIOCSBRK, 0);
56
-  usleep (10);
57
+  usleep (10+t_on);
58
   addr = 0;
59
 }
60
 
61
 void picport::delay (long ns)
62
 {
63
-  if (1 == use_nanosleep) {
64
+  if (1 == use_nanosleep && !t_edge) {
65
     timespec ts = {ns / 1000000000, ns % 1000000000}, ts2;
66
     while (nanosleep (&ts, &ts2) && EINTR == errno)
67
       ts = ts2;
68
@@ -232,7 +237,7 @@
69
   }
70
 
71
 #ifdef RDTSC_WORKS
72
-  if (tsc_1000ns > 1) {
73
+  if (tsc_1000ns > 1 && !t_edge) {
74
     unsigned long a1, d1, a2, d2;
75
     asm volatile("rdtsc":"=a" (a1), "=d" (d1));
76
     d2 = d1;
77
@@ -259,10 +264,10 @@
78
   volatile int i;
79
   gettimeofday (&tv1, 0);
80
   tv2.tv_sec = tv1.tv_sec;
81
-  tv2.tv_usec = 0xffffffff & (tv1.tv_usec + 1 + (ns + 999)/1000);
82
+  tv2.tv_usec = 0xffffffff & (tv1.tv_usec + 1 + (ns + 999)/1000+t_edge);
83
   if (tv2.tv_usec < tv1.tv_usec)
84
     tv2.tv_sec++;
85
-  for (i = 0; i < 10000; i++) {
86
+  for (i = 0; i < 10000 || t_edge; i++) {
87
     gettimeofday (&tv1, 0);
88
     if (tv1.tv_sec > tv2.tv_sec
89
 	|| tv1.tv_sec == tv2.tv_sec && tv1.tv_usec >= tv2.tv_usec)
(-)devel/picprog/files/patch-picport.h (+13 lines)
Added Link Here
1
--- picport.h.orig	Thu Apr 29 00:09:38 2004
2
+++ picport.h	Fri Jul  8 21:46:07 2005
3
@@ -59,6 +59,10 @@
4
 
5
 public:
6
 
7
+  static int t_on;
8
+  static int t_off;
9
+  static int t_edge;
10
+
11
   static void delay (long ns);
12
 
13
   enum commands {
(-)devel/picprog/files/patch-program.h (-3 / +3 lines)
Lines 1-6 Link Here
1
--- program.h.orig	Tue Nov 19 12:53:12 2002
1
--- program.h.orig	Thu Jan  1 20:35:09 2004
2
+++ program.h	Tue Nov 19 12:53:20 2002
2
+++ program.h	Fri Jul  8 21:44:23 2005
3
@@ -31,6 +31,7 @@
3
@@ -30,6 +30,7 @@
4
 #ifndef H_PROGRAM
4
 #ifndef H_PROGRAM
5
 #define H_PROGRAM
5
 #define H_PROGRAM

Return to bug 83174