1From dblank@comp.uark.edu  Wed Jul  1 13:17:17 1998
2Received: from aleve.media.mit.edu by hub.media.mit.edu; (5.65v3.2/1.1/06Jun95-8.2MPM)
3	id AA10324; Wed, 1 Jul 1998 13:17:17 -0400
4Received: from comp.uark.edu (root@comp.uark.edu [130.184.252.197])
5	by aleve.media.mit.edu (8.8.7/ML970927) with ESMTP id LAA00083
6	for <handyboard@media.mit.edu>; Wed, 1 Jul 1998 11:56:44 -0400 (EDT)
7Received: from comp.uark.edu (IDENT:dblank@dangermouse.uark.edu [130.184.201.233])
8	by comp.uark.edu (8.9.0/8.9.0) with ESMTP id KAA12202;
9	Wed, 1 Jul 1998 10:56:30 -0500 (CDT)
10Sender: dblank@comp.uark.edu
11Date: Wed, 01 Jul 1998 10:56:30 -0500
12From: Douglas Blank <dblank@comp.uark.edu>
13Organization: University of Arkansas, CS
14X-Mailer: Mozilla 4.04 [en] (X11; I; Linux 2.0.33 i686)
15Mime-Version: 1.0
16To: Aaron Edsinger <aarone@sirius.com>
17Cc: handy <handyboard@media.mit.edu>
18Subject: Re: Serial Interface
19References: <199807010601.XAA26862@mail3.sirius.com>
20Content-Type: text/plain; charset=us-ascii
21Content-Transfer-Encoding: 7bit
22
23Aaron Edsinger wrote:
24
25> Hello,
26>         I've been having some problems using my HandyBoard to talk directly to my
27> PC via the serial interface.  I disable Interactive C and then Poke() and
28> Peek() as has been described on this list.  I  send short character strings
29> from my PC to the HandyBoard under Windows 95.  If I send strings longer
30> than 2 characters, it seems that some of the characters get lost. This
31> behavior seems to be affected by repositioning or slightly modifying the
32> code, suggesting perhaps a timing issue.
33
34Although there is the HEXMON program, I too, have been trying to do what
35you describe, and encountered the same problems. I found it to be a
36timing issue, and, through trial and error, have a found some settings
37that seem to work most of the time.
38
39My goal was to make C code that looked the same when compiled and run on
40the Host is the code that ran under IC.
41
42I am including the host and HB programs here. If anyone knows of a
43better way of communicating, please let us know.
44
45-Doug Blank
46
47=====================================================================
48dblank@comp.uark.edu            Douglas Blank, University of Arkansas
49Assistant Professor                                  Computer Science
50==================== http://www.uark.edu/~dblank ====================
51
52This code was written for MS C++4.0 running on Win95.
53
54//************** BEGIN: serial_HOST.c
55
56/* VC++4.0 HandyBoard Host Programming System
57   Dr. Douglas S. Blank
58   University of Arkansas, Department of Computer Science
59   www.uark.edu/~dblank
60
61   This code runs on a host PC.
62*/
63
64#include <ctype.h>
65#include <conio.h>
66#include <stdlib.h>
67#include <stdio.h>
68
69#include "serial_HOST.h"
70
71void main(int argc, char *argv[])
72{
73        motor(0, 100);
74        motor(1, 100);
75        motor(2, 100);
76        motor(3, 100);
77        sleep(1000);
78        motor(0, -100);
79        motor(1, -100);
80        motor(2, -100);
81        motor(3, -100);
82        sleep(1000);
83        ao();
84        print("\nThis is a test");
85        printf("Knob is %d\n", knob() );
86        printf("Analog(0) is %d\n", analog(0));
87        printf("Digital(0) is %d\n", digital(0));
88        printf("Analog(1) is %d\n", analog(1));
89        printf("Digital(1) is %d\n", digital(1));
90        printf("Analog(2) is %d\n", analog(2));
91        printf("Digital(2) is %d\n", digital(2));
92        printf("Analog(3) is %d\n", analog(3));
93        printf("Digital(3) is %d\n", digital(3));
94        printf("Analog(4) is %d\n", analog(4));
95        printf("Digital(4) is %d\n", digital(4));
96        printf("Analog(5) is %d\n", analog(5));
97        printf("Digital(5) is %d\n", digital(5));
98        printf("Analog(6) is %d\n", analog(6));
99        printf("Digital(6) is %d\n", digital(6));
100        printf("Analog(7) is %d\n", analog(7));
101        printf("Digital(7) is %d\n", digital(7));
102        printf("Analog(8) is %d\n", analog(8));
103        printf("Digital(8) is %d\n", digital(8));
104        printf("Analog(9) is %d\n", analog(9));
105        printf("Digital(9) is %d\n", digital(9));
106        printf("Analog(10) is %d\n", analog(10));
107        printf("Digital(10) is %d\n", digital(10));
108        printf("Analog(11) is %d\n", analog(11));
109        printf("Digital(11) is %d\n", digital(11));
110        printf("Analog(12) is %d\n", analog(12));
111        printf("Digital(12) is %d\n", digital(12));
112        printf("Analog(13) is %d\n", analog(13));
113        printf("Digital(13) is %d\n", digital(13));
114        printf("Analog(14) is %d\n", analog(14));
115        printf("Digital(14) is %d\n", digital(14));
116        printf("Analog(15) is %d\n", analog(15));
117        printf("Digital(15) is %d\n", digital(15));
118        beep();
119        sleep(1000);
120        while (! stop_button() ) {
121                sprintf(buffer, "%d.0", (knob() * 10));
122                tone( buffer, "0.1");
123        }
124}
125
126//************** END: serial_HOST.c
127
128//************** BEGIN: serial_HOST.h
129
130/* VC++4.0 HandyBoard Host Programming System
131   Dr. Douglas S. Blank
132   University of Arkansas, Department of Computer Science
133   www.uark.edu/~dblank
134*/
135
136#define MOTOR     0
137#define AO        1
138#define ANALOG    2
139#define DIGITAL   3
140#define PRINTF    4
141#define KNOB      5
142#define BEEP      6
143#define TONE      7
144#define START_BUTTON 8
145#define STOP_BUTTON  9
146#define QUIT    113
147
148#define sleep(NUM) _sleep(NUM)
149#define SERIALWAIT  5
150
151unsigned short PORT = 0x3f8; // LPT1: 0x378 COM1: 0x3f8
152
153int send(int i) {
154        int retval;
155        retval = _outp( PORT, i);
156        _sleep(SERIALWAIT);
157        return retval;
158}
159
160int receive() {
161        int retval;
162        retval = _inp( PORT);
163        _sleep(SERIALWAIT);
164        retval = _inp( PORT);
165        return retval;
166}
167
168void hangup() {
169        send(QUIT);
170}
171
172void print(char buffer[]) {
173        int i;
174        send(PRINTF);
175        for (i = 0; buffer[i] != 0; i++)
176                send(buffer[i]);
177        send('\0');
178}
179
180void motor(int motornum, int power) {
181        send(MOTOR);
182        send(motornum);
183        send(power + 100); // taken off on the other end
184}
185
186int analog(int sensor) {
187        send(ANALOG);
188        send(sensor);
189        return receive();
190}
191
192int digital(int sensor) {
193        send(DIGITAL);
194        send(sensor);
195        return receive();
196}
197
198void ao() {
199        send(AO);
200}
201
202int knob() {
203        send(KNOB);
204        return receive();
205}
206
207void beep() {
208        send(BEEP);
209}
210
211void tone(char f1[], char f2[]) {
212        int i;
213        send(TONE);
214        for (i = 0; f1[i] != 0; i++)
215                send(f1[i]);
216        send('\0');
217        for (i = 0; f2[i] != 0; i++)
218                send(f2[i]);
219        send('\0');
220        _sleep((unsigned long) (atof(f2) * 1000)); // to keep from
221overflowing serial line
222}
223
224void interactive()
225{
226        char c;
227        char key = ' ';
228        while (key != 'q') {
229                key = getch();
230                send(key);
231                printf("Sent %c\n", key);
232                c = receive();
233                printf("Got %c as a return value\n", c);
234        }
235}
236
237int start_button() {
238        send(START_BUTTON);
239        return receive();
240}
241
242int stop_button() {
243        send(STOP_BUTTON);
244        return receive();
245}
246//************** END: serial_HOST.h
247
248//************** BEGIN: serial_HB.c
249
250/* VC++4.0 HandyBoard Programming System
251   (Parts taken from other HB programs)
252   Dr. Douglas S. Blank
253   University of Arkansas, Department of Computer Science
254   www.uark.edu/~dblank
255
256   This code runs on the HB
257*/
258
259#define MOTOR     0
260#define AO        1
261#define ANALOG    2
262#define DIGITAL   3
263#define PRINTF    4
264#define KNOB      5
265#define BEEP    6
266#define TONE    7
267#define START_BUTTON 8
268#define STOP_BUTTON  9
269#define QUIT    113
270
271int _isspace(int a)         /* returns 1 for space or tab, 0
272otherwise     */
273                            /* internal routine used by atof() and
274cgets() */
275
276{
277    return ((a == 32) || (a == 9));     /* 32 is space, 9 is tab */
278}
279
280/*****************************************************************************/
281
282int _isdigit(int a)         /* returns 1 if a digit 0-9, 0 otherwise */
283                            /* internal routine used by atof()       */
284
285{
286    return ((a >= 48) && (a <= 57));    /* 48 is '0', 57 is '9' */
287}
288
289float atof(char s[])    /* Convert a string containing a number in
290ASCII     */
291                        /* form (integer, float, or exponential float)
292to a  */
293                        /* float.  Strips whitespace characters (space
294and   */
295                        /* tab) from the front of the string, but
296stops      */
297                        /* parsing at the first (unexpected)
298non-numeric     */
299                        /* character if the string has garbage at the
300end.   */
301                        /* This means that "  34.3foo78" translates to
30234.3. */
303                        /* Modified from atof() function in the
304standard     */
305                        /* library of the Hi-Tec C compiler for
306CP/M.        */
307                        /* Note:  all string literals converted to
308decimal   */
309                        /* form because IC can't deal with string
310literals   */
311                        /* in math
312calculations.                             */
313                        /* Also note:  very ugly code because IC will
314not    */
315                        /* allow any math operations on pointers!  Thus,
316the */
317                        /* the number string has to be treated as an
318array!  */
319                        /* Also also note:  no error handling; assumes
320that  */
321                        /* the string is a valid representation of a
322number! */
323                        /* Valid range for exponential-format numbers
324is     */
325                        /* approximately 2.0e-38 to
3263.4e+38.                 */
327
328{
329    int     i=0;            /* index into string array */
330    int     sign=0;         /* mantissa sign flag:  0=positive,
3311=negative */
332    int     exp0=0;         /* mantissa exponent counter */
333    int     eexp=0;         /* E-form exponent counter */
334    int     expsign=0;      /* exponent sign flag:  0=positive,
3351=negative */
336    float   m=0.0;          /* mantissa accumulator */
337
338    /* skip any leading whitespace (space, tab) */
339    while (_isspace(s[i]))
340        i++;                                /* skip it */
341
342    /* check for mantissa sign */
343    if (s[i] == 45)                         /* 45 is '-' */
344    {
345        sign = 1;                           /* flag minus sign */
346        i++;                                /* point to next */
347    }
348    else if (s[i] == 43)                    /* 43 is '+' */
349        i++;                                /* point to next */
350
351    /* now get all digits up to either a decimal point or an e/E */
352    while (_isdigit(s[i]))
353    {
354        m = 10.0*m + (float)(s[i] - 48);    /* 48 is '0' */
355        i++;                                /* point to next */
356    }
357
358    /* no more digits, so check for decimal point */
359    if (s[i] == 46)                         /* 46 is '.' */
360    {
361        i++;                                /* point to next */
362        /* get all digits after decimal point */
363        while (_isdigit(s[i]))
364        {
365            exp0--;
366            m = 10.0*m + (float)(s[i] - 48);    /* 48 is '0' */
367            i++;                                /* point to next */
368        }
369    }
370
371    /* check for e/E exponential form */
372    if ((s[i] == 101) || (s[i] == 69))      /* 101 is 'e', 69 is 'E' */
373    {
374        i++;                                /* point to next */
375        /* check for exponent sign */
376        if (s[i] == 45)                     /* 45 is '-' */
377        {
378            expsign = 1;                    /* flag negative exponent */
379            i++;                            /* point to next */
380        }
381        else if (s[i] == 43)                /* 43 is '+' */
382            i++;                            /* point to next */
383
384        /* now get exponent */
385        while (_isdigit(s[i]))
386        {
387            eexp = eexp*10 + s[i] - 48;     /* 48 is '0' */
388            i++;                            /* point to next */
389        }
390
391        /* adjust exponent sign */
392        if (expsign)
393            eexp = -eexp;                   /* make it negative */
394    }
395
396    /* compute absolute value of final float */
397    exp0 += eexp;
398    while (exp0 < 0)                    /* for negative exponents */
399    {
400        m = m / 10.0;
401        exp0++;
402    }
403    while (exp0 > 0)                    /* for positive exponents */
404    {
405        m = m * 10.0;
406        exp0--;
407    }
408
409    /* adjust final float sign from mantissa */
410    if (sign)
411        return (-m);                    /* negative */
412    else
413        return (m);                     /* positive */
414}
415
416void disable_pcode_serial()
417/* necessary to receive characters using serial_getchar */
418{
419   poke(0x3c, 1);
420}
421
422void reenable_pcode_serial()
423/* necessary for IC to interact with board again */
424{
425   poke(0x3c, 0);
426}
427
428/*
429======================================================================
430For sending and receiving single bytes, you can use Randy's IC code:
431*/
432
433void serial_putchar(int c)
434{
435   while (!(peek(0x102e) & 0x80));  /* wait until serial transmit empty
436*/
437   poke(0x102f, c);  /* send character */
438}
439
440int serial_getchar()
441{
442   while (!(peek(0x102e) & 0x20)); /* wait for received character */
443   return peek(0x102f);
444}
445
446void main(void) {
447        int pos, c = ' ', var1, var2;
448        float f1, f2;
449        char buffer[80];
450        disable_pcode_serial();
451        beep();
452        printf("\nSerial IO Mode!");
453        printf("Listening...");
454        msleep(500L);
455        while (c != 'q') {
456                c = serial_getchar();
457/*              printf("[%d] ", c); */
458                if (c == MOTOR) {
459                        var1 = serial_getchar();
460                        var2 = serial_getchar() - 100;
461                        motor(var1, var2);
462                } else if (c == AO) {
463                        ao();
464                } else if (c == ANALOG) {
465                        var1 = serial_getchar();
466                        serial_putchar(analog(var1));
467                } else if (c == DIGITAL) {
468                        var1 = serial_getchar();
469                        serial_putchar(digital(var1));
470                } else if (c == PRINTF) {
471                        pos = 0;
472                        while (c != 0) {
473                                buffer[pos++] = c;
474                                c = serial_getchar();
475                        }
476                        buffer[pos] = '\0';
477                        printf(buffer);
478                } else if (c == TONE) {
479                        pos = 0;
480                        c = serial_getchar();
481                        while (c != 0) {
482                                buffer[pos++] = c;
483                                c = serial_getchar();
484                        }
485                        buffer[pos] = '\0';
486                        f1 = atof(buffer);
487                        pos = 0;
488                        c = serial_getchar();
489                        while (c != 0) {
490                                buffer[pos++] = c;
491                                c = serial_getchar();
492                        }
493                        buffer[pos] = '\0';
494                        f2 = atof(buffer);
495                        tone(f1, f2);
496                } else if (c == START_BUTTON) {
497                        serial_putchar(start_button());
498                } else if (c == STOP_BUTTON) {
499                        serial_putchar(stop_button());
500                } else if (c == BEEP) {
501                        beep();
502                } else if (c == KNOB) {
503                        serial_putchar(knob());
504                }
505      }
506        reenable_pcode_serial();
507        printf("\nHB Mode!");
508}
509
510//************** END: serial_HB.c
511
512From goldt@et.byu.edu  Tue Jul  7 20:33:03 1998 WETDST
513Received: from aleve.media.mit.edu by hub.media.mit.edu; (5.65v3.2/1.1/06Jun95-8.2MPM)
514	id AA32480; Tue, 7 Jul 1998 20:33:03 -0400
515Received: from wormwood.ee.byu.edu (wormwood.ee.byu.edu [128.187.30.54])
516	by aleve.media.mit.edu (8.8.7/ML970927) with ESMTP id TAA30127
517	for <handyboard@media.mit.edu>; Tue, 7 Jul 1998 19:48:43 -0400 (EDT)
518Received: from wormwood (localhost [127.0.0.1]) by wormwood.ee.byu.edu with SMTP (8.7.6/8.7.1) id RAA26916 for <handyboard@media.mit.edu>; Tue, 7 Jul 1998 17:48:42 -0600 (MDT)
519Sender: goldt@ee.byu.edu
520Date: Tue, 07 Jul 1998 17:48:41 -0600
521From: "Timothy B. Gold" <goldt@et.byu.edu>
522X-Mailer: Mozilla 3.04Gold (X11; I; HP-UX B.10.20 9000/780)
523Mime-Version: 1.0
524To: handyboard@media.mit.edu
525Subject: Interrupt Handler for Serial communication
526Content-Type: multipart/mixed; boundary="------------18CC6AC44E2E"
527
528This is a multi-part message in MIME format.
529
530--------------18CC6AC44E2E
531Content-Type: text/plain; charset=us-ascii
532Content-Transfer-Encoding: 7bit
533
534Here's a bit of code that will buffer incoming serial information so
535that no information will be lost when transmitting to the handy board.
536There are two files: serial_isr.c and serial_isr.asm.  You'll need to
537assemble the .asm file using as11_ic, and then both the .c file and the
538.icb file need to be loaded onto the handy board.  I'm sure improvements
539could be made to the code to clean it up a little, but it's a start (and
540I haven't had any problems with it yet).  Enjoy!
541
542--------------18CC6AC44E2E
543Content-Type: text/plain; charset=us-ascii; name="serial_isr.c"
544Content-Transfer-Encoding: 7bit
545Content-Disposition: inline; filename="serial_isr.c"
546
547/* C program to read serial port with interrupt service routine */
548/* First version:  Written by Anton Wirsch   20 Nov 1997 */
549
550/*
551
552   Second Version: Written by Tim Gold   27 May 1998
553                              BYU Robotics Lab
554			      goldt@et.byu.edu
555
556     Really, the only thing left from the original code are a few
557     lines in the .asm file.  Everything else I pretty much had to
558     rewrite from scratch to get it to work the way I wanted to.
559     But the orignal code by Anton was a very helpful starting point.
560
561  Needed files:   serial_isr.c
562                  serial_isr.icb
563		  serial_isr.asm (needed to change the buffer size)
564
565  The buffer size here is 32 bytes (probably much larger than it needs
566  to be.)  To change the buffer size, do the following:
567              1. Change the BUFFER_SIZE constant below to the
568	         desired number of bytes.
569	      2. Edit the line(s) in the serial_isr.asm which contain
570	         the word "EDIT" in the comment so that the value
571		 matches that of BUFFER_SIZE.
572	      3. Recreate the serial_isr.icb file by typing the following:
573	         > as11_ic serial_isr.asm
574
575 */
576
577
578
579
580#define BUFFER_SIZE 32  /* change buffer size here  -- see above */
581
582/* various constants used by the program... */
583#define BAUD 0x102b   /* baud rate set to 9600 */
584#define SCCR2 0x102d
585#define SCCR1 0x102c
586#define SCSR 0x102e
587#define SCDR 0x102f
588
589int buffer[BUFFER_SIZE]; /* this is the actual buffer */
590
591
592void initSerial()
593{
594  /* Call this routine to activate the serial interrupt handler. */
595  int i,temp;
596
597  /* clear out buffer */
598  for(i=0; i<BUFFER_SIZE; i++)
599    buffer[i] = 0;
600
601  /* clear vairous flags */
602  DATA_FLAG = 0;
603  INCOMING = 0;
604  CURRENT = 0;
605
606  /* pass address of buffer to interrupt routine */
607  buffer_ptr = (int) buffer;
608  BASE_ADDR = (int) buffer;
609
610  /* activate interrupt routine */
611  temp = peek(SCCR2);
612  temp |= 0x24;
613  poke(SCCR2, temp);
614  poke(0x3c, 1);
615}
616
617void closeSerial()
618{
619  int temp;
620
621  /* deactivate the interrupt routine */
622  temp = peek(SCCR2);
623  temp &= 0xdf;
624  poke(SCCR2, temp);
625  READ_SERIAL = 0x0000;
626  poke(0x3c, 0);
627
628}
629
630void serialPutChar(int c)
631{
632  /* call this function to write a character to the serial port */
633
634  while (!(peek(0x102e) & 0x80));
635  poke(0x102f, c);
636
637}
638
639
640int dataAvailable()
641{
642  /* This function can be used to check to see if any data is available */
643  return DATA_FLAG;
644}
645
646
647int serialGetChar()
648{
649  /* Create blocking getchar for serial port... */
650  int return_char;
651
652  /* loop until data is available */
653  while(!DATA_FLAG);
654
655  /* get the character to return */
656  return_char = buffer[CURRENT];
657
658  /* check for wrap around... */
659  CURRENT++;
660  if(CURRENT == BUFFER_SIZE)
661    CURRENT = 0;
662  if(CURRENT == INCOMING)
663    DATA_FLAG = 0;
664  return return_char;
665
666}
667
668
669
670
671
672--------------18CC6AC44E2E
673Content-Type: text/plain; charset=us-ascii; name="serial_isr.asm"
674Content-Transfer-Encoding: 7bit
675Content-Disposition: inline; filename="serial_isr.asm"
676
677/* This sets up the serial interrupt service routine */
678/* First Version:	Written by Anton L. Wirsch  20 Nov 1997 */
679/* Second Version: Written by Tim Gold   27 May 1998
680                              BYU Robotics Lab
681		              goldt@et.byu.edu
682
683     Really, the only thing left from the original code are a few
684     lines in the .asm file.  Everything else I pretty much had to
685     rewrite from scratch to get it to work the way I wanted to.
686     But the orignal code by Anton was a very helpful starting point.
687
688  Needed files:   serial_isr.c
689                  serial_isr.icb
690		  serial_isr.asm (needed to change the buffer size)
691
692  The buffer size here is 32 bytes (probably much larger than it needs
693  to be.)  To change the buffer size, do the following:
694              1. Change the BUFFER_SIZE constant in serial_isr.c to the
695	         desired number of bytes.
696	      2. Edit the line in this fils which contains
697	         the word "EDIT" in the comment so that the value
698		 matches that of BUFFER_SIZE.
699	      3. Recreate the serial_isr.icb file by typing the following:
700	         > as11_ic serial_isr.asm
701*/
702
703
704/* change this line to match your library path... */
705#include "/usr/local/ic/libs/6811regs.asm"
706
707        ORG MAIN_START
708variable_CURRENT:
709	FDB    00        * ptr to next data to be read by user
710
711variable_INCOMING:
712        FDB    00        * number of bytes received (circular count)
713
714variable_BASE_ADDR:
715	FDB    00        * base address of buffer (to be set by init routine)
716
717variable_DATA_FLAG:
718        FDB    00        * flag set when data is available
719
720variable_buffer_ptr:
721        FDB    00        * pointer to CURRENT buffer
722
723subroutine_initialize_module:
724/* change this line to match your library path... */
725#include "/usr/local/ic/libs/ldxibase.asm"
726
727        ldd     SCIINT,X
728        std     interrupt_code_exit+1
729        ldd     #interrupt_code_start
730        std     SCIINT,X
731
732	rts
733
734interrupt_code_start:
735        ldad    variable_INCOMING       * store INCOMING into AB
736        cmpb    #00                     * compare B with 0
737        bhi     skip                    * goto "skip" if (B > 0)
738        ldx     variable_BASE_ADDR      * STORE ADDRESS OF ARRY IN X
739        inx                             * SKIP THE FIRST (?)
740        inx                             * TWO BYTES      (?)
741        inx                             * OFFSET TO THE HIGHER BYTE (?)
742        stx     variable_buffer_ptr     * SAVE PTR VALUE
743        bra     cont
744
745skip:
746        ldx     variable_buffer_ptr     * load buffer pointer into x
747cont:
748        ldad    variable_INCOMING       * load INCOMING into AB
749        incb                            * increment INCOMING
750	cmpb    #32                     * compare B and 32   --EDIT TO CHANGE BUFFER SIZE--
751	beq     reset_count             * if a=32, goto reset_count
752	bra     cont1
753reset_count:
754	ldad    #00                     * set count to zero
755cont1:
756        stad    variable_INCOMING       * store AB into INCOMING
757
758        ldab    SCSR                    * load SCSR (SCI status register) into B (why?)
759        ldab    SCDR                    * load SCSR (SCI data register) into B
760
761        stab    ,X                      * store data in array
762        inx                             * increment by two bytes
763        inx
764        stx     variable_buffer_ptr     * save the pointer value
765	ldad    #01                     * load 1 into AB
766	stad    variable_DATA_FLAG      * store AB into DATA_FLAG (indicating data is available)
767interrupt_code_exit:
768        jmp     $0000
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785--------------18CC6AC44E2E--
786
787
788
789From aarone@sirius.com  Wed Jul  1 02:44:06 1998 MEST
790Received: from aleve.media.mit.edu by hub.media.mit.edu; (5.65v3.2/1.1/06Jun95-8.2MPM)
791	id AA22669; Wed, 1 Jul 1998 02:44:06 -0400
792Received: from mail3.sirius.com (mail3.sirius.com [205.134.253.133])
793	by aleve.media.mit.edu (8.8.7/ML970927) with ESMTP id CAA13214
794	for <handyboard@media.mit.edu>; Wed, 1 Jul 1998 02:01:55 -0400 (EDT)
795Received: from edsinger (ppp-asfm03--126.sirius.net [205.134.240.126])
796	by mail3.sirius.com (8.8.7/Sirius-8.8.7-97.08.12) with ESMTP id XAA26862
797	for <handyboard@media.mit.edu>; Tue, 30 Jun 1998 23:01:54 -0700 (PDT)
798From: "Aaron Edsinger" <aarone@sirius.com>
799To: "handy" <handyboard@media.mit.edu>
800Subject: Serial Interface
801Date: Wed, 1 Jul 1998 02:06:39 +0100
802X-Msmail-Priority: Normal
803X-Priority: 3
804X-Mailer: Microsoft Internet Mail 4.70.1162
805Mime-Version: 1.0
806Content-Type: text/plain; charset=ISO-8859-1
807Content-Transfer-Encoding: 7bit
808
809Hello,
810	I've been having some problems using my HandyBoard to talk directly to my
811PC via the serial interface.  I disable Interactive C and then Poke() and
812Peek() as has been described on this list.  I  send short character strings
813from my PC to the HandyBoard under Windows 95.  If I send strings longer
814than 2 characters, it seems that some of the characters get lost. This
815behavior seems to be affected by repositioning or slightly modifying the
816code, suggesting perhaps a timing issue.
817
818Why might this be?  Is there any way to check for an error situation?
819
820Thanks for any help,
821		Aaron
822From cmcmanis@freegate.com  Thu Jul 16 03:13:49 1998
823Received: from aleve.media.mit.edu by hub.media.mit.edu; (5.65v3.2/1.1/06Jun95-8.2MPM)
824	id AA23518; Thu, 16 Jul 1998 03:13:49 -0400
825Received: from hq.freegate.com ([208.226.86.1])
826	by aleve.media.mit.edu (8.8.7/ML970927) with SMTP id CAA18991
827	for <handyboard@media.mit.edu>; Thu, 16 Jul 1998 02:17:47 -0400 (EDT)
828Received: (qmail+freegate 6968 invoked by alias); 16 Jul 1998 06:17:38 -0000
829Received: from dialip-04.hq.freegate.com (HELO freegate.com) (208.226.86.222)
830  by hq.freegate.com with SMTP; 16 Jul 1998 06:17:38 -0000
831Date: Wed, 15 Jul 1998 23:21:14 -0700
832From: Chuck McManis <cmcmanis@freegate.com>
833Reply-To: cmcmanis@freegate.com
834Organization: Freegate Corporation
835X-Mailer: Mozilla 4.04 [en] (Win95; I)
836Mime-Version: 1.0
837To: David Rye <rye@mech.eng.usyd.edu.au>
838Cc: handyboard@media.mit.edu
839Subject: Re: Handyboard/RWP without p-code
840References: <3.0.32.19980716151646.00809d20@nemo.mech.eng.usyd.edu.au>
841Content-Type: text/plain; charset=us-ascii
842Content-Transfer-Encoding: 7bit
843
844Get a copy of icc11 v5.0 or later (from www.imagecraft.com) and use the
845handyboard library from their site.
846
847--Chuck
848
849From Scott.Seaton@Aus.Sun.COM  Thu Jul 16 03:42:38 1998
850Received: from aleve.media.mit.edu by hub.media.mit.edu; (5.65v3.2/1.1/06Jun95-8.2MPM)
851	id AA24945; Thu, 16 Jul 1998 03:42:38 -0400
852Received: from mercury.Sun.COM (mercury.Sun.COM [192.9.25.1])
853	by aleve.media.mit.edu (8.8.7/ML970927) with SMTP id CAA07415
854	for <handyboard@media.mit.edu>; Thu, 16 Jul 1998 02:44:58 -0400 (EDT)
855Received: from Aus.Sun.COM ([129.158.80.6]) by mercury.Sun.COM (SMI-8.6/mail.byaddr) with SMTP id XAA29734; Wed, 15 Jul 1998 23:44:52 -0700
856Received: from war.Aus.Sun.COM by Aus.Sun.COM id QAA03011
857	(SMI-8.6/SMI-4.1 for <>); Thu, 16 Jul 1998 16:44:50 +1000
858Received: from drone by war.Aus.Sun.COM (SMI-8.6/SMI-SVR4)
859	id QAA10921; Thu, 16 Jul 1998 16:44:20 +1000
860Date: Thu, 16 Jul 1998 16:41:56 +1000 (EST)
861From: Scott Seaton - Systems Consultant - ESG <Scott.Seaton@Aus.Sun.COM>
862Reply-To: Scott Seaton - Systems Consultant - ESG <Scott.Seaton@Aus.Sun.COM>
863Subject: Re: Handyboard/RWP without p-code
864To: handyboard@media.mit.edu, rye@mech.eng.usyd.edu.au
865Mime-Version: 1.0
866Content-Type: MULTIPART/mixed; BOUNDARY=Troop_of_Baboons_752_000
867X-Mailer: dtmail 1.2.0 CDE Version 1.2 SunOS 5.6 sun4u sparc
868
869--Troop_of_Baboons_752_000
870Content-Type: TEXT/plain; charset=us-ascii
871Content-MD5: i/HKSIa/Vk0mZT5ml+q21A==
872
873Hi
874
875I suggest that you contact ImageCraft.
876http://www.imagecraft.com/software/index.html  or  info@imagecraft.com
877
878They have a C compiler for 68HC11 CPU's that will do what you want, including a
879library for the HandyBoard (see attached e-mail) !
880
881I have no affiliation with ImageCraft (other than as a satisfied customer).
882
883Hope this helps
884Scott
885==============================================================================
886 ,-_|\       Scott Seaton - Sun Enterprise Services -  Systems Consultant
887/     \  Sun Microsystems Australia Pty Ltd  E-mail : scott.seaton@aus.sun.com
888\_,-\_+  828 Pacific Highway                  Phone : +61 2 9844 5381
889     v   Gordon, N.S.W., 2072, AUSTRALIA        Fax : +61 2 9844 5161
890==============================================================================
891
892--Troop_of_Baboons_752_000
893Content-Type: MESSAGE/rfc822; name=Mailbox
894Content-Description: Mailbox
895
896From someone@imagecraft.com  Fri Jul 10 18:59:26 1998
897Return-Path: <icc11-list-errors@lists.best.com>
898Received: from Aus.Sun.COM by war.Aus.Sun.COM (SMI-8.6/SMI-SVR4)
899	id SAA14426; Fri, 10 Jul 1998 18:59:26 +1000
900Received: from earth.sun.com by Aus.Sun.COM id SAA24238
901	(SMI-8.6/SMI-4.1 for <<scott.seaton@aus.sun.com>>); Fri, 10 Jul 1998 18:59:48 +1000
902Received: from iisesun.iise.CSIRO.AU (iisesun.iise.csiro.au [130.155.5.44])
903	by earth.sun.com (8.8.8/8.8.8) with SMTP id BAA18609
904	for <scott.seaton@aus.sun.com>; Fri, 10 Jul 1998 01:59:44 -0700 (PDT)
905Received: from lists1.best.com (lists1.best.com [206.86.8.15]) by iisesun.iise.CSIRO.AU (SMI-8.6/8.6.12-IISE-SWA) with ESMTP id SAA25847 for <sseaton@iise.csiro.au>; Fri, 10 Jul 1998 18:49:31 +1000
906Received: (from daemon@localhost) by lists1.best.com (8.9.0/8.8.BEST) id BAA15320 for icc11-list-errors@lists.best.com; Fri, 10 Jul 1998 01:04:34 -0700 (PDT)
907Message-Id: <199807100804.BAA15320@lists1.best.com>
908From: Christina Willrich & Richard Man <someone@imagecraft.com>
909Subject: icc11 Handyboard library available
910Date: Fri, 10 Jul 1998 00:58:49 -0700
911BestServHost: lists.best.com
912MIME-Version: 1.0
913Content-Type: text/plain; charset="us-ascii"
914Sender: icc11-list-errors@lists.best.com
915Errors-To: icc11-list-errors@lists.best.com
916Reply-To: icc11-list@lists.best.com
917To: icc11-list@lists.best.com
918content-length: 399
919Status: RO
920X-Status: $$$$
921X-UID: 0000000001
922
923At long last, I dusted off Chuck McManis Handyboard library and ported it
924to V5. No reason why it can't work with V4.5 either ;-) Anyway, to try it
925out, point your browser to
926
927ftp://ftp.imagecraft.com/pub/libhb.zip
928
929Chuck really did a great job with the LCD. There are commands to scroll,
930move etc. Make sure you try the lcdtest2.c test.
931
932// richard
933someone@imagecraft.com http://www.imagecraft.com
934
935From someone2@imagecraft.com  Fri Jul 10 18:59:26 1998
936Return-Path: <icc11-list-errors@lists.best.com>
937Received: from Aus.Sun.COM by war.Aus.Sun.COM (SMI-8.6/SMI-SVR4)
938	id SAA14426; Fri, 10 Jul 1998 18:59:26 +1000
939Received: from earth.sun.com by Aus.Sun.COM id SAA24238
940	(SMI-8.6/SMI-4.1 for <<scott.seaton@aus.sun.com>>); Fri, 10 Jul 1998 18:59:48 +1000
941Received: from iisesun.iise.CSIRO.AU (iisesun.iise.csiro.au [130.155.5.44])
942	by earth.sun.com (8.8.8/8.8.8) with SMTP id BAA18609
943	for <scott.seaton@aus.sun.com>; Fri, 10 Jul 1998 01:59:44 -0700 (PDT)
944Received: from lists1.best.com (lists1.best.com [206.86.8.15]) by iisesun.iise.CSIRO.AU (SMI-8.6/8.6.12-IISE-SWA) with ESMTP id SAA25847 for <sseaton@iise.csiro.au>; Fri, 10 Jul 1998 18:49:31 +1000
945Received: (from daemon@localhost) by lists1.best.com (8.9.0/8.8.BEST) id BAA15320 for icc11-list-errors@lists.best.com; Fri, 10 Jul 1998 01:04:34 -0700 (PDT)
946Message-Id: <199807100804.BAA15320@lists1.best.com2>
947From: Christina Willrich & Richard Man <someone@imagecraft.com>
948Subject: icc11 Handyboard library available 2
949Date: Fri, 10 Jul 1998 00:58:49 -0700
950BestServHost: lists.best.com
951MIME-Version: 1.0
952Content-Type: text/plain; charset="us-ascii"
953Sender: icc11-list-errors@lists.best.com
954Errors-To: icc11-list-errors@lists.best.com
955Reply-To: icc11-list@lists.best.com
956To: icc11-list@lists.best.com
957content-length: 399
958Status: RO
959X-Status: $$$$
960X-UID: 0000000001
961
962At long last, I dusted off Chuck McManis Handyboard library and ported it
963to V5. No reason why it can't work with V4.5 either ;-) Anyway, to try it
964out, point your browser to
965
966ftp://ftp.imagecraft.com/pub/libhb.zip
967
968Chuck really did a great job with the LCD. There are commands to scroll,
969move etc. Make sure you try the lcdtest2.c test.
970
971// richard
972someone@imagecraft.com http://www.imagecraft.com
973
974
975--Troop_of_Baboons_752_000--
976
977From dakott@alpha.delta.edu  Wed Jul  1 05:33:51 1998
978Received: from aleve.media.mit.edu by hub.media.mit.edu; (5.65v3.2/1.1/06Jun95-8.2MPM)
979	id AA20653; Wed, 1 Jul 1998 05:33:51 -0400
980Received: from alpha.delta.edu (alpha.delta.edu [161.133.129.3])
981	by aleve.media.mit.edu (8.8.7/ML970927) with SMTP id EAA12514
982	for <handyboard@media.mit.edu>; Wed, 1 Jul 1998 04:41:22 -0400 (EDT)
983Received: from pm295-18.dialip.mich.net by alpha.delta.edu; (5.65v3.0/1.1.8.2/06Jan97-0932AM)
984	id AA31111; Wed, 1 Jul 1998 04:44:45 -0400
985Received: from kott.my.domain (dakott@kott.my.domain [192.168.0.1])
986	by kott.my.domain (8.8.8/8.8.5) with SMTP id WAA20239;
987	Tue, 30 Jun 1998 22:34:32 -0400 (EDT)
988Date: Tue, 30 Jun 1998 22:34:31 -0400 (EDT)
989From: David Kott <dakott@alpha.delta.edu>
990Sender: dakott@kott.my.domain
991To: brian-c@technologist.com
992Cc: handyboard@media.mit.edu
993Subject: Re: microcontroller
994In-Reply-To: <199806291430.KAA07909@web01.globecomm.net>
995Mime-Version: 1.0
996Content-Type: TEXT/PLAIN; charset=US-ASCII
997
998On Mon, 29 Jun 1998 brian-c@technologist.com wrote:
999
1000> -I'd like to say thanks to all the folks who replied
1001> to my question on the microcontroller speeds.
1002>
1003> Here's another general question about them though.
1004> Should any unused pins be left open or should they
1005> be grounded?
1006>
1007
1008Eeeeeeeeeeek!  Outputs left floating, CMOS inputs taken to ground with a
10094.7K resistor... presuming, of course, that a Logic 0 on that input won't
1010generate adverse effects, e.g. a grounded active low interrupt line
1011might be a problem.  Such inputs should be taken to +5 with a 4.7K
1012resistor.
1013
1014Floating CMOS inputs have a tendency to oscillate with the merest whisper
1015of a voltage.
1016
1017TTL inputs may be left floating.
1018
1019Driving an output externally will just heat up your CPU.. or worse.
1020
1021							-d
1022
1023--
1024 The box said "Requires Windows 95/NT or better"...
1025                                                 So I got Unix.
1026
1027Free the Source.  Free your Computer... http://www.FreeBSD.org
1028                                          http://www.NetBSD.org
1029                                            http://www.OpenBSD.org
1030
1031From rshirk@sfgate.com  Sun Mar 22 01:52:45 1998
1032Received: from aleve.media.mit.edu by hub.media.mit.edu; (5.65v3.2/1.1/06Jun95-8.2MPM)
1033	id AA06355; Sun, 22 Mar 1998 01:52:45 -0500
1034Received: from cyber.sfgate.com (cyber.sfgate.com [198.93.154.11])
1035	by aleve.media.mit.edu (8.8.7/ML970927) with SMTP id BAA23676
1036	for <handyboard@media.mit.edu>; Sun, 22 Mar 1998 01:08:09 -0500 (EST)
1037Received: from localhost by cyber.sfgate.com  with smtp
1038	(Smail3.2 #1) id m0yGduz-000Is1C; Sat, 21 Mar 1998 22:07:37 -0800 (PST)
1039Date: Sat, 21 Mar 1998 22:07:37 -0800 (PST)
1040From: Richard <rshirk@sfgate.com>
1041X-Sender: rshirk@cyber
1042To: handyboard@media.mit.edu
1043Subject: Frob nobs and IR
1044Mime-Version: 1.0
1045Content-Type: MULTIPART/MIXED; BOUNDARY="-559023410-1804928587-890546857=:21628"
1046
1047  This message is in MIME format.  The first part should be readable text,
1048  while the remaining parts are likely unreadable without MIME-aware tools.
1049  Send mail to mime@docserver.cac.washington.edu for more info.
1050
1051---559023410-1804928587-890546857=:21628
1052Content-Type: TEXT/PLAIN; charset=US-ASCII
1053
1054OK...Im now pretty happy with states of things but I still have a few
1055questions I hope you can help me answer. The code attached works and
1056everything, but only when i take the bit about playing the songs out.
1057
1058problem 1)
1059 It
1060keeps saying that play is undefined.  I saw that before and fixed it by
1061changing the names of the labels of the songs.  I tried it this time and
1062it didnt work...i was wondering if anyone out there knows why it does this
1063and how to correct it....
1064
1065problem 2)
1066
1067I figured out (thanks to you guys) how to work the built in IR sensor to
1068detect and act upon 4 signals. One is for behing hostile, 3 is for
1069seeking, signal 5 is when it gets annoyed, and 7 it just beeps and ignores
1070it.
1071The signal for being Hostile responds quickly and prints H on the screen
1072but the others lag and  i was wondering if you knew why this was.
1073
1074-Richard
1075
1076---559023410-1804928587-890546857=:21628
1077Content-Type: TEXT/PLAIN; charset=US-ASCII; name="xbump2.c"
1078Content-Transfer-Encoding: BASE64
1079Content-ID: <Pine.SOL.3.96.980321220737.21628D@cyber>
1080Content-Description:
1081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ICAgICB9
1099DSAgICAgICAgICBlbHNlIGlmICgoIGtub2IoICkgKSA9PSAwKQ0gICAgICAg
1100ICAgew0gICAgICAgICAgICAgICAgcGxheSAobHR1bmVfc29uZyk7DSAgICAg
1101ICAgICB9DSAgICAgICAgICAgICAgICBlbHNlIGlmICgoIGtub2IoICkgKSA9
1102PSAxMTYpDSAgICAgICAgICB7DSAgICAgICAgICAgICAgICBwcmludGYoIkhF
1103TExPLCBKVURHRVMhXG4iKTsNICAgICAgICAgICAgICAgIG1zbGVlcCg1MDBM
1104KTsNICAgICAgICAgIH0NICAgIH0NDSAgIHByaW50ZiggIlByZXNzIFNUQVJU
1105XG4iICk7DSAgIHN0YXJ0X3ByZXNzKCk7ICAgLyogd2FpdCAndGlsIGJ1dHRv
1106biBpcyBwcmVzc2VkICovDSAgIGJlZXAoKTsNICAgcHJpbnRmKCAiU3RhbmQg
1107YmFjay4uLlxuIiApOw0gICBzbGVlcCggMS4wICk7IA0gICAvKiBpbml0aWF0
1108ZSBmb3J3YXJkIG1vdGlvbiAqLw0gICBmZCggMiApOw0gICBmZCggMyApOw0g
1109ICB3aGlsZSggMSApICAgLyogZmVlZGJhY2sgbG9vcCAqLw0gICB7DSAgICAg
1110IGlmKCAhIGRpZ2l0YWwoIDcgKSApICAgLyogY2hlY2sgbGVmdCBidW1wZXIg
1111Ki8NICAgICAgew0gICAgICAgICAvKiByZXZlcnNlICovDSAgICAgICAgIGJl
1112ZXAoKTsNICAgICAgICAgYmsoIDIgKTsNICAgICAgICAgYmsoIDMgKTsNICAg
1113ICAgICAgbXNsZWVwKCByZXZlcnNlX3RpbWUgKTsNDSAgICAgICAgIC8qIHR1
1114cm4gcmlnaHQgKi8NICAgICAgICAgZmQoIDIgKTsNICAgICAgICAgYmsoIDMg
1115KTsNICAgICAgICAgbXNsZWVwKCB0dXJuX3RpbWUgKTsNDSAgICAgICAgIC8q
1116IHJlc2V0IGZvcndhcmQgbW90aW9uICovDSAgICAgICAgIHByaW50ZiggIjAi
1117ICk7DSAgICAgICAgIGZkKCAyICk7DSAgICAgICAgIGZkKCAzICk7DQ0gICAg
1118ICB9DQ0gICAgICBlbHNlIGlmKCAhIGRpZ2l0YWwoIDExICkgKSAgIC8qIGNo
1119ZWNrIG1pZGRsZSBidW1wZXIgKi8NICAgICAgew0gICAgICAgICAvKiByZXZl
1120cnNlICovDSAgICAgICAgIGJlZXAoKTsNICAgICAgICAgYmsoIDIgKTsNICAg
1121ICAgICAgYmsoIDMgKTsNICAgICAgICAgbXNsZWVwKCByZXZlcnNlX3RpbWUg
1122KTsNDSAgICAgICAgIC8qIHR1cm4gYXJvdW5kICovDSAgICAgICAgIGZkKCAy
1123ICk7DSAgICAgICAgIGJrKCAzICk7DSAgICAgICAgIG1zbGVlcCggdHVybmFy
1124b3VuZF90aW1lICk7DQ0gICAgICAgICAvKiByZXNldCBmb3J3YXJkIG1vdGlv
1125biAqLw0gICAgICAgICBwcmludGYoICIxIiApOw0gICAgICAgICBmZCggMiAp
1126Ow0gICAgICAgICBmZCggMyApOw0gICAgICB9DQ0gICAgICBlbHNlIGlmKCAh
1127IGRpZ2l0YWwoIDE1ICkgKSAgIC8qIGNoZWNrIHJpZ2h0IGJ1bXBlciAqLw0g
1128ICAgICB7DSAgICAgICAgIC8qIHJldmVyc2UgKi8NICAgICAgICAgYmVlcCgp
1129Ow0gICAgICAgICBiayggMiApOw0gICAgICAgICBiayggMyApOw0gICAgICAg
1130ICBtc2xlZXAoIHJldmVyc2VfdGltZSApOw0NICAgICAgICAgLyogdHVybiBs
1131ZWZ0ICovDSAgICAgICAgIGJrKCAyICk7DSAgICAgICAgIGZkKCAzICk7DSAg
1132ICAgICAgIG1zbGVlcCggdHVybl90aW1lICk7DQ0gICAgICAgICAvKiByZXNl
1133dCBmb3J3YXJkIG1vdGlvbiAqLw0gICAgICAgICBwcmludGYoICIyIiApOw0g
1134ICAgICAgICBmZCggMiApOw0gICAgICAgICBmZCggMyApOw0gICAgIH0NICAg
1135ICBlbHNlIGlmKGlyX2RhdGEoIDAgKSA9PSAxMjggKSAvKkNoZWNrIElSIHJl
1136Y2lldmVyKi8NICAgICAgew0gICAgICAgICAgcHJpbnRmKCJIIik7DSAgICAg
1137ICAgIC8qIHR1cm4gcmlnaHQgKi8NICAgICAgICAgZmQoIDIgKTsNICAgICAg
1138ICAgYmsoIDMgKTsNICAgICAgICAgbXNsZWVwKCB0dXJuX3RpbWUgKTsNICAg
1139ICAgICAgIC8qQXR0YWNrLi4uUm9ib3QgaXMgSG9zdGlsZSAqLw0gICAgICAg
1140ICAgYmVlcCgpOyANICAgICAgICAgIGZkKCAyICk7DSAgICAgICAgICBmZCgg
1141MyApOw0gICAgICAgICAgYmVlcCgpOw0gICAgIH0NICAgICBlbHNlIGlmKGly
1142X2RhdGEoIDAgKSA9PSAxMzAgKSAvKkNoZWNrIElSIHJlY2lldmVyKi8NICAg
1143ICAgew0gICAgICAgICAgcHJpbnRmKCJTIik7DSAgICAgICAgIC8qIHR1cm4g
1144cmlnaHQgKi8NICAgICAgICAgZmQoIDIgKTsNICAgICAgICAgYmsoIDMgKTsN
1145ICAgICAgICAgbXNsZWVwKCB0dXJuX3RpbWUgKTsNICAgICAgICAgIC8qUm9i
1146b3QgaXMgaW4gbG92ZSEgRG8gYSBsaWwgZGFuY2UhICovDSAgICAgICAgICBi
1147ZWVwKCk7DSAgICAgICAgICBiZWVwKCk7IA0gICAgICAgICAgZmQoIDIgKTsN
1148ICAgICAgICAgIGZkKCAzICk7DSAgICAgICAgICBtc2xlZXAoIHR1cm5fdGlt
1149ZSApOw0gICAgICAgICAgYmsoIDIgKTsNICAgICAgICAgIGJrKCAzICk7DSAg
1150ICAgICAgICBtc2xlZXAoIHJldmVyc2VfdGltZSApOyANICAgICAgICAgIC8q
1151R28gZm9yd2FyZCEqLw0gICAgICAgICAgZmQoIDIgKTsNICAgICAgICAgIGZk
1152KCAzICk7DSAgICAgICAgICBiZWVwKCk7DSAgICAgICAgICBiZWVwKCk7DSAg
1153ICAgfQ0gICAgIGVsc2UgaWYoaXJfZGF0YSggMCApID09IDEzMiApIC8qQ2hl
1154Y2sgSVIgcmVjaWV2ZXIqLw0gICAgICB7DSAgICAgICAgICBwcmludGYoIkEi
1155KTsNICAgICAgICAvKiByZXZlcnNlICovDSAgICAgICAgIGJlZXAoKTsNICAg
1156ICAgICAgYmsoIDIgKTsNICAgICAgICAgYmsoIDMgKTsNICAgICAgICAgbXNs
1157ZWVwKCByZXZlcnNlX3RpbWUgKTsNICAgICAgICAgIC8qUm9ib3QgaXMgQW5u
1158b3llZCEgVHVybnMgY29tcGxldGVseSBhcm91bmQgaW4gZGlndXN0Ki8gICAg
1159ICAgDSAgICAgICAgIGJlZXAoKTsNICAgICAgICAgYmVlcCgpOyANICAgICAg
1160ICAgYmVlcCgpOw0gICAgICAgICBmZCggMiApOw0gICAgICAgICBiayggMyAp
1161Ow0gICAgICAgICBtc2xlZXAoIHR1cm5hcm91bmRfdGltZSApOw0gICAgICAg
1162ICAgZmQoIDIgKTsNICAgICAgICAgIGZkKCAzICk7DSAgICAgICAgICBiZWVw
1163KCk7DSAgICAgICAgICBiZWVwKCk7IA0gICAgICAgICAgYmVlcCgpOw0NICAg
1164ICB9DSAgICAgZWxzZSBpZihpcl9kYXRhKCAwICkgPT0gMTM0ICkgLypDaGVj
1165ayBJUiByZWNpZXZlciovDSAgICAgIHsNICAgICAgICAgIHByaW50ZigiSSIp
1166Ow0gICAgICAgICAgLypSb2JvdCBkb2Vzbid0IGNhcmUgKi8NICAgICAgICAg
1167IGJlZXAoKTsgDSAgICAgICAgICBiZWVwKCk7DSAgICAgICAgICBiZWVwKCk7
1168IA0gICAgICAgICAgYmVlcCgpOw0gICAgICAgICAgZmQoIDIgKTsNICAgICAg
1169ICAgIGZkKCAzICk7DSAgICAgICAgICBiZWVwKCk7DSAgICAgICAgICBiZWVw
1170KCk7DSAgICAgICAgICBiZWVwKCk7IA0gICAgICAgICAgYmVlcCgpOw0gDSAg
1171ICB9DQ0gICB9DX0N
1172---559023410-1804928587-890546857=:21628--
1173
1174From wallace@theory.phys.vt.edu  Mon Jul 27 18:34:05 1998
1175Received: from aleve.media.mit.edu by hub.media.mit.edu; (5.65v3.2/1.1/06Jun95-8.2MPM)
1176	id AA00723; Mon, 27 Jul 1998 18:34:05 -0400
1177Received: from theory.phys.vt.edu (theory.phys.vt.edu [128.173.176.33])
1178	by aleve.media.mit.edu (8.8.7/ML970927) with ESMTP id RAA19984
1179	for <handyboard@media.mit.edu>; Mon, 27 Jul 1998 17:22:26 -0400 (EDT)
1180Received: from localhost (wallace@localhost)
1181	by theory.phys.vt.edu (8.8.5/8.8.5) with SMTP id RAA00312
1182	for <handyboard@media.mit.edu>; Mon, 27 Jul 1998 17:22:24 -0400 (EDT)
1183Date: Mon, 27 Jul 1998 17:22:24 -0400 (EDT)
1184From: Mark Wallace <wallace@theory.phys.vt.edu>
1185To: handyboard@media.mit.edu
1186Subject: sonar.c for the handyboard
1187Mime-Version: 1.0
1188Content-Type: TEXT/PLAIN; charset=US-ASCII
1189
1190Hello,
1191	I have a handyboard and 6500 series poloroid ultrasonic ranging
1192system.  I have downloaded the sonar.c programs used to drive the
1193transducer for distance measurements.  There appears to be a problem, or
1194atleast I think there is, with it.  The sonar device is supposed to give
1195distances of up to 35ft but the TCNC time register is 16 bit and in the
1196program it says "if ((peekwork(0x100e)-start_time) < 0)" too much time has
1197elapsed and it returns -1.  Therefore as soon as about 32700 counts goes
1198by, that value will go negative. I believe hex goes from 0 to 32768 then
1199-32768 to -1. In this case the difference will be < 0 if the object
1200is greater then about 9 ft.  I have taken this out of the program and can
1201get accurate measurements up to atleast 30 ft but I have to look at the
1202value given and add multiples of 2^16 to it to figure out where it is.
1203Taking this out of the program also can get you stuck if you really are
1204out of range.
1205	I have looked on the motorola web pages to see about this clock
1206and it says that the clock goes till it reachs $ffff and then flags
1207somewhere that there is an overflow and then starts over.  I don't know
1208how to find out were in the chip this information might be stored.  I know
1209the TCNT time register is at 0x100e from the notes on Simplified Sonar for
1210the Handy Board but I don't know where that overflow flag is stored.  I
1211thought that maybe by setting this flag and using it in the loop you might
1212be about to get a greater distance out of you measurement.
1213	Another question I have is about IC.  I would like to display
1214numbers greater then 32000 and right now there are several int type
1215variables and normal C comands don't seem to work to make a "long" or any
1216other type that are larger then 32000.  How does IC handle larger numbers?
1217	I am only a student and don't have much experience with this stuff
1218so I would appreciate any feedback I can get on either of these problems.
1219Thanks.
1220
1221Mark Wallace
1222
1223 e-mail  mawalla3@vt.edu
1224         wallace@astro.phys.vt.edu
1225Web page http://sps1.phys.vt.edu/~mwallace/index.html
1226
1227"What a waste it would be after 4 billion tortuous years of evolution if
1228the dominant organism contrived its own self-destruction"
1229                                        Carl Sagan
1230
1231
1232From mwallace@sps1.phys.vt.edu  Mon Aug  3 12:05:51 1998
1233Received: from aleve.media.mit.edu by hub.media.mit.edu; (5.65v3.2/1.1/06Jun95-8.2MPM)
1234	id AA15988; Mon, 3 Aug 1998 12:05:51 -0400
1235Received: from sps1.phys.vt.edu (sps1.phys.vt.edu [128.173.176.53])
1236	by aleve.media.mit.edu (8.8.7/ML970927) with ESMTP id LAA12381
1237	for <handyboard@media.mit.edu>; Mon, 3 Aug 1998 11:16:53 -0400 (EDT)
1238Received: from localhost (mwallace@localhost)
1239	by sps1.phys.vt.edu (8.8.7/8.8.7) with SMTP id LAA20283;
1240	Mon, 3 Aug 1998 11:16:50 -0400
1241Date: Mon, 3 Aug 1998 11:16:50 -0400 (EDT)
1242From: Mark Wallace <mwallace@sps1.phys.vt.edu>
1243To: alf.kuchenbuch@usa.net
1244Cc: handyboard@media.mit.edu
1245Subject: Re: Polaroid trouble again
1246In-Reply-To: <35C5C521.446B@eikon.e-technik.tu-muenchen.de>
1247Mime-Version: 1.0
1248Content-Type: TEXT/PLAIN; charset=US-ASCII
1249
1250	I had this same problem when I got mine a few weeks ago.  I ended up
1251putting a capacitor from pin 1 to pin 3 on U2 of the sonar driver board.
1252I also had to take out the 1k resistor from the BINH.  It kept
1253BINH at 1 V instead of Zero and that seamed to cause problems.
1254	As for the 6 ft problem,  it should be closer to 9 ft.  I think
1255the problem there is the IC code you used.  If you used the code for
1256SONAR.C from the HB web site then there is a problem with it.  What that
1257program does is take the difference in time from the internal clock.  the
1258problem is that in the code it says that if the difference between start
1259time and currnet time is negative too much time has elapsed.  Well,  this
1260has a 16 bit counter so when the difference is greater the about 32,700 it
1261becomes negative.  If you do the math, that means at about 9 ft that
1262happens so it tell you you are out of range.
1263	The way I fixed this was to slow the clock down.
1264
1265I looked up information on the motorola web page and found where the
1266prescalers were for the clock.
1267	If you want to slow it down by a factor of four you can just add
1268this line to you program in sonar_init()
1269
1270	bit_set(0x1024, 1);
1271
1272I believe bit_set(0x1024, 2); will slow it down by a factor of 8 and
1273bit_set(0x1024, 3); will slow it down by a factor of 16.
1274	There are better ways of fixing this problem but they appear much
1275more complicated.  For example the motorola chip has an overflow flag that
1276says when the internal clock flips.  You could incorporate that into your
1277code instead of slowing the clock down.  Good luck and I hope this helps.
1278
1279Mark Wallace
1280
1281 e-mail  mawalla3@vt.edu
1282         mwallace@sps1.phys.vt.edu
1283Web page http://sps1.phys.vt.edu/~mwallace/index.html
1284
1285"What a waste it would be after 4 billion tortuous years of evolution if
1286the dominant organism contrived its own self-destruction"
1287                                        Carl Sagan
1288
1289On Mon, 3 Aug 1998, Alf Kuchenbuch wrote:
1290
1291> Hi!
1292> I am having trouble with my Polaroid sonar:
1293> When I keep my HB hooked up
1294> to external power, I will only get correct readings up to 20 inches. As
1295> soon as I use battery power without hooking it up to external power, the
1296> readings are correct up to 6 feet, not more! This sound like EMI, I
1297> guess. I tried all the capacitor tricks from HB mailing list, but in
1298> vain. Do you know a fix that works?
1299>
1300> Alf H. Kuchenbuch
1301>
1302
1303
1304From mawalla3@vt.edu  Wed Aug 12 13:10:06 1998
1305Received: from aleve.media.mit.edu by hub.media.mit.edu; (5.65v3.2/1.1/06Jun95-8.2MPM)
1306	id AA07529; Wed, 12 Aug 1998 13:10:06 -0400
1307Received: from quackerjack.cc.vt.edu (root@quackerjack.cc.vt.edu [198.82.160.250])
1308	by aleve.media.mit.edu (8.8.7/ML970927) with ESMTP id MAA05729
1309	for <Handyboard@media.mit.edu>; Wed, 12 Aug 1998 12:13:53 -0400 (EDT)
1310Received: from sable.cc.vt.edu (sable.cc.vt.edu [128.173.16.30])
1311	by quackerjack.cc.vt.edu (8.8.8/8.8.8) with ESMTP id MAA20678
1312	for <Handyboard@media.mit.edu>; Wed, 12 Aug 1998 12:20:09 -0400 (EDT)
1313Received: from research10.phys.vt.edu (dhcp9.phys.vt.edu [128.173.176.166])
1314	by sable.cc.vt.edu (8.8.8/8.8.8) with SMTP id MAA05159
1315	for <Handyboard@media.mit.edu>; Wed, 12 Aug 1998 12:13:51 -0400 (EDT)
1316X-Sender: mawalla3@mail.vt.edu (Unverified)
1317X-Mailer: QUALCOMM Windows Eudora Light Version 3.0.5 (32)
1318Date: Wed, 12 Aug 1998 12:13:45 -0400
1319To: Handyboard@media.mit.edu
1320From: Mark Wallace <mawalla3@vt.edu>
1321Subject: serial library for C++
1322Mime-Version: 1.0
1323Content-Type: text/plain; charset="us-ascii"
1324
1325Hello,
1326	I have a handy board with poloroid transducers and I am trying use the
1327results of my distance measurments in a C++ program on the computer.  I
1328have found programs on the handyboard web page that should alow the
1329handyboard to transmit information over the serial line.  What I am looking
1330for is if anyone knows were I could find a serial for Microsofts
1331Visual C++ 5.0.  I would like to find one that is free or sharware but any
1332information on any serial that will work would be appreciated.
1333Thanks.
1334Mark Wallace
1335
1336 e-mail  mawalla3@vt.edu
1337	 mwallace@sps1.phys.vt.edu
1338web page http://sps1.phys.vt.ede/~mwallace
1339
1340"What a waist it would be after 4 billion tortuous years of evolution if
1341the dominant organism contrived its own self-distruction"
1342			Carl Sagan
1343
1344
1345From aarone@sirius.com  Wed Sep 30 12:35:05 1998
1346Received: from aleve.media.mit.edu by hub.media.mit.edu; (5.65v4.0/1.1/06Jun95-8.2MPM)
1347	id AA09172; Wed, 30 Sep 1998 12:35:05 -0400
1348Received: from mail3.sirius.com (mail3.sirius.com [205.134.253.133])
1349	by aleve.media.mit.edu (8.8.7/ML970927) with ESMTP id KAA02849
1350	for <handyboard@media.mit.edu>; Wed, 30 Sep 1998 10:46:53 -0400 (EDT)
1351Received: from aarone (ppp-asfm03--129.sirius.net [205.134.240.129])
1352	by mail3.sirius.com (8.8.7/Sirius-8.8.7-97.08.12) with SMTP id HAA08635;
1353	Wed, 30 Sep 1998 07:46:49 -0700 (PDT)
1354From: "Aaron Edsinger" <aarone@sirius.com>
1355To: "Keith - Lui" <luikeith@egr.msu.edu>
1356Cc: "handy" <handyboard@media.mit.edu>
1357Subject: Re: output to file
1358Date: Wed, 30 Sep 1998 10:47:58 -0700
1359Mime-Version: 1.0
1360Content-Type: text/plain;
1361	charset="iso-8859-1"
1362Content-Transfer-Encoding: 7bit
1363X-Priority: 3
1364X-Msmail-Priority: Normal
1365X-Mailer: Microsoft Outlook Express 4.72.2106.4
1366X-Mimeole: Produced By Microsoft MimeOLE V4.72.2106.4
1367
1368Yes,
1369        Write a dos/windows client that reads the serial line and then
1370writes it to file using the C stdio library.
1371
1372
1373-----Original Message-----
1374From: Keith - Lui <luikeith@egr.msu.edu>
1375To: handyboard@media.mit.edu <handyboard@media.mit.edu>
1376Date: Wednesday, September 30, 1998 6:55 AM
1377Subject: output to file
1378
1379
1380>Dear all,
1381>
1382>I would like to output some HB data to a file, is that possible?
1383>
1384>Keith
1385>
1386
1387
1388
1389From aarone@sirius.com  Wed Aug 12 13:42:19 1998
1390Received: from aleve.media.mit.edu by hub.media.mit.edu; (5.65v3.2/1.1/06Jun95-8.2MPM)
1391	id AA13439; Wed, 12 Aug 1998 13:42:19 -0400
1392Received: from mail3.sirius.com (mail3.sirius.com [205.134.253.133])
1393	by aleve.media.mit.edu (8.8.7/ML970927) with ESMTP id MAA10630
1394	for <handyboard@media.mit.edu>; Wed, 12 Aug 1998 12:48:27 -0400 (EDT)
1395Received: from aarone (ppp-asfm05--041.sirius.net [205.134.241.41])
1396	by mail3.sirius.com (8.8.7/Sirius-8.8.7-97.08.12) with SMTP id JAA20821;
1397	Wed, 12 Aug 1998 09:48:24 -0700 (PDT)
1398From: "Aaron Edsinger" <aarone@sirius.com>
1399To: "Mark Wallace" <mawalla3@vt.edu>
1400Cc: "handy" <handyboard@media.mit.edu>
1401Subject: Re: serial library for C++
1402Date: Wed, 12 Aug 1998 12:53:41 -0700
1403Mime-Version: 1.0
1404Content-Type: text/plain;
1405	charset="iso-8859-1"
1406Content-Transfer-Encoding: 7bit
1407X-Priority: 3
1408X-Msmail-Priority: Normal
1409X-Mailer: Microsoft Outlook Express 4.72.2106.4
1410X-Mimeole: Produced By Microsoft MimeOLE V4.72.2106.4
1411
1412
1413  Check out this site.  It works well.  The only problem I had was timing
1414issues when trying to read and write to the port too quickly.
1415
1416http://www.codeguru.com/show.cgi?general=/misc/misc_toc.shtml
1417
1418
1419-----Original Message-----
1420From: Mark Wallace <mawalla3@vt.edu>
1421To: Handyboard@media.mit.edu <Handyboard@media.mit.edu>
1422Date: Wednesday, August 12, 1998 9:25 AM
1423Subject: serial library for C++
1424
1425
1426>Hello,
1427> I have a handy board with poloroid transducers and I am trying use the
1428>results of my distance measurments in a C++ program on the computer.  I
1429>have found programs on the handyboard web page that should alow the
1430>handyboard to transmit information over the serial line.  What I am looking
1431>for is if anyone knows were I could find a serial library for Microsofts
1432>Visual C++ 5.0.  I would like to find one that is free or sharware but any
1433>information on any serial librarys that will work would be appreciated.
1434>Thanks.
1435>Mark Wallace
1436>
1437> e-mail  mawalla3@vt.edu
1438> mwallace@sps1.phys.vt.edu
1439>web page http://sps1.phys.vt.ede/~mwallace
1440>
1441>"What a waist it would be after 4 billion tortuous years of evolution if
1442>the dominant organism contrived its own self-distruction"
1443> Carl Sagan
1444>
1445
1446From brian-c@technologist.com  Mon Jul  6 11:54:19 1998
1447Received: from aleve.media.mit.edu by hub.media.mit.edu; (5.65v3.2/1.1/06Jun95-8.2MPM)
1448	id AA03667; Mon,  6 Jul 1998 11:54:19 -0400
1449Received: from web04.globecomm.net (web04.globecomm.net [207.51.48.104])
1450	by aleve.media.mit.edu (8.8.7/ML970927) with ESMTP id TAA30534
1451	for <handyboard@media.mit.edu>; Mon, 6 Jul 1998 19:24:28 -0400 (EDT)
1452From: brian-c@technologist.com
1453Received: (from root@localhost) by web04.globecomm.net (8.8.8/8.8.0) id TAA03097; Mon, 6 Jul 1998 11:24:27 -0400 (EDT)
1454Date: Mon, 6 Jul 1998 11:24:27 -0400 (EDT)
1455Content-Type: multipart/mixed; boundary="0-0-0-0-0-0-0-0-____====$%&"
1456Mime-Version: 1.0
1457To: Terri A Mortvedt <terrim@iastate.edu>, handyboard@media.mit.edu
1458Subject: Re: Steppers
1459
1460--0-0-0-0-0-0-0-0-____====$%&
1461Content-Type: text/plain
1462Content-Transfer-Encoding: quoted-printable
1463X-MIME-Autoconverted: from 8bit to quoted-printable by aleve.media.mit.edu id TAA30534
1464
1465Dear Terri,
1466
1467If the motors turn sparatically, that means the coils
1468are probably not hooked up in the correct order. Try
1469swapping them around and see if anything improves.
1470
1471The motors you are using are the bipolar type. There=20
1472is a decent way of hooking up unipolar steppers to
1473the HB at http://www.cctc.demon.co.uk/stepper.htm
1474A basic difference between bipolar and unipolar is
1475that unipolar motors have additional wires are=20
1476connected to the power supply. Bipolars also have more
1477torque.
1478
1479Using fd(); and bk(); commands to power steppers is
1480probably a lot to handle. I recommend trying the=20
1481method found on that link. There's even sample coding.
1482You will have to modify some variables for the turn
1483functions because your turning radius varies according
1484to your distance between motors.
1485
1486I modified the step(); function to produce a gradual=20
1487increase in speed, and a gradual decrease in speed once
1488the specified steps are almost complete.=20
1489
1490I will attach my motors.c file as is.
1491
1492
1493
1494_________________________________________________
1495=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=
1496=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF
1497Brian Carvalho              [ brian-c@ieee.org ]
1498DeVRY Institute
1499New Jersey
1500_________________________________________________
1501=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=
1502=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF
1503---------------------------------------------------
1504Get free personalized email at http://www.iname.com
1505
1506--0-0-0-0-0-0-0-0-____====$%&
1507Content-Type: application/octet-stream
1508Content-disposition: inline; filename=Motors.c
1509Content-Transfer-Encoding: base64
1510
1511
1512
1513LyogTW90b3JzLmMgKi8NCg0KLyoqKiBERUNMQVJBVElPTlMgKioqLw0KDQppbnQgRk9SV0FSRFMg
1514PSAwOyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKiB2YXJpYWJsZXMgZm9yIGRpcmVj
1515dGlvbiAqLw0KaW50IEJBQ0tXQVJEUyA9IDE7DQogDQppbnQgSEFMRlRVUk4gPSA3MDsgICAgICAg
1516ICAgICAgICAgICAgICAgICAgICAgIC8qIHZhcmlhYmxlcyBmb3IgdHVybmluZyAqLw0KaW50IFFV
1517QVJURVJUVVJOID0gSEFMRlRVUk4gLyAyOw0KIA0KaW50IFJJR0hUID0gMjsgICAgICAgICAgICAg
1518ICAgICAgICAgICAgICAgICAgICAgLyogdmFsdWVzIGZvciB0dXJucyAqLw0KaW50IExFRlQgPSA4
1519Ow0KDQppbnQgcmlnaHRfbW90b3JfcG9pbnRlciA9IDA7ICAgICAgICAgICAgICAgICAgICAvKiBt
1520b3RvciBjb250cm9sIHZhbHVlcyAqLw0KaW50IGxlZnRfbW90b3JfcG9pbnRlciA9IDA7DQogDQog
1521DQppbnQgY3ljbGVfbGVuZ3RoID0gNDsgICAgICAgICAgICAgICAgICAgICAgICAgICAvKiBoYWxm
1522IHN0ZXBwaW5nIH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NCgkJCQkJICBzdGVwcGVyc19v
1563dXQoKTsNCgkJCQkJICBtc2xlZXAoU0xPVyk7DQoJCQl9DQp9DQoNCg0Kdm9pZCBzdGVwIChpbnQg
1564ZGlyLCBpbnQgbnVtc3RlcHMsIGludCBkZWxheSkNCnsNCiAgICAgICAgaW50IHN0ZXAsc3RwOw0K
1565ICAgICAgICBpbnQgYmVnaW49bnVtc3RlcHMvMTA7DQoJaW50IGNvbnRpbnVlOw0KICAgICAgICBs
1566b25nIGdyYWQ9KGxvbmcpYmVnaW47DQoNCglzeXN0ZW1fcHdtX29mZigpOw0KDQoJZm9yIChzdGVw
1567PTA7c3RlcDxiZWdpbjtzdGVwKyspDQoJew0KCQltc2xlZXAoZ3JhZCk7DQoJCWxlZnRfc3RlcChk
1568aXIpOw0KCQlyaWdodF9zdGVwKGRpcik7DQoJCXN0ZXBwZXJzX291dCgpOw0KCQljb250aW51ZT1z
1569dGVwOw0KICAgICAgICAgICAgICAgIGdyYWQ9Z3JhZC0xTDsNCg0KCX0NCiAgICAgICAgd2hpbGUo
1570Y29udGludWU8YmVnaW4qOSkNCgl7DQoJCW1zbGVlcCgobG9uZylkZWxheSk7DQoJCWxlZnRfc3Rl
1571cChkaXIpOw0KCQlyaWdodF9zdGVwKGRpcik7DQoJCXN0ZXBwZXJzX291dCgpOw0KCQljb250aW51
1572ZSsrOw0KICAgICAgICAgICAgICAgIHN0cD1jb250aW51ZTsNCgkgfQ0KDQogICAgICAgICB3aGls
1573ZShzdHA8bnVtc3RlcHMpDQogICAgICAgICB7DQogICAgICAgICAgICAgIGRlbGF5PWRlbGF5KzE7
1574DQogICAgICAgICAgICAgIG1zbGVlcCgobG9uZylkZWxheSk7DQogICAgICAgICAgICAgIGxlZnRf
1575c3RlcChkaXIpOw0KICAgICAgICAgICAgICByaWdodF9zdGVwKGRpcik7DQogICAgICAgICAgICAg
1576IHN0ZXBwZXJzX291dCgpOw0KICAgICAgICAgICAgICBzdHArKzsNCiAgICAgICAgIH0NCglhbygp
1577Ow0KDQp9ICAgICAgICAgICAgICAgICAgICAgICAgICAgICANCg0K
1578
1579
1580--0-0-0-0-0-0-0-0-____====$%&--
1581