To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.handyboardOpen lugnet.robotics.handyboard in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / Handy Board / 3691
3690  |  3692
Subject: 
Re: Serial Communication: HB -> Win95
Newsgroups: 
lugnet.robotics.handyboard
Date: 
Wed, 22 Apr 1998 14:11:01 GMT
Original-From: 
Douglas Blank <DBLANK@COMP.UARKspamless.EDU>
Viewed: 
627 times
  
To answer my own question, at least partially, here is a Win95 Host
program to communicate (single bytes) with the HandyBoard over a serial
line:

/* Win95 Visual C++ Host Code to talk to HandyBoard */

#include <conio.h> // _outp, _inp
#include <stdlib.h> // sleep
#include <stdio.h> // printf

unsigned short PORT = 0x3f8; // COM1: 0x3f8 on my computer

int send(char c) {
        return _outp( PORT, c);
}

char receive() {
        char retval;
        retval = _inp( PORT);
        _sleep(50);                  // this was necessary; too fast a
machine?
        retval = _inp( PORT);
        return retval;
}


void main(int argc, char *argv[])
{
        char c;
        char key = ' ';
        while (key != 'q') {
                key = getch();
                send(key);
                printf("Sent %c\n", key);
                c = receive();
                printf("Got %c as a return value\n", c);
        }
}


Here is a sample HB program to talk to:

void disable_pcode_serial()
/* necessary to receive characters using serial_getchar */
{
   poke(0x3c, 1);
}

void reenable_pcode_serial()
/* necessary for IC to interact with board again */
{
   poke(0x3c, 0);
}

/*
======================================================================
For sending and receiving single bytes, you can use Randy's IC code:
*/

void serial_putchar(int c)
{
   while (!(peek(0x102e) & 0x80));  /* wait until serial transmit empty
*/
   poke(0x102f, c);  /* send character */
}

int serial_getchar()
{
   while (!(peek(0x102e) & 0x20)); /* wait for received character */
   return peek(0x102f);
}

void main(void) {
        char c = ' ';
        disable_pcode_serial();
        while (c != 'q') {
                c = serial_getchar();
                printf("\nReceived = %c   ", c);
                if (c == '1') {
                        serial_putchar(analog(0));
                } else if (c == 'a') {
                        serial_putchar(knob());
                }

      }
        reenable_pcode_serial();
        printf("\nHB Mode!");
}


If anyone has a better solution, please let me know.

-Doug Blank

Douglas Blank wrote:

I am using the serial_putchar() and serial_getchar() communication routines
on the HandyBoard, and everything is working fine from the PC to the HB.
However, I am having trouble getting the HB to send data back to the PC.

=====================================================================
dblank@comp.uark.edu            Douglas Blank, University of Arkansas
Assistant Professor                                  Computer Science
==================== http://www.uark.edu/~dblank ====================



Message is in Reply To:
  Serial Communication: HB -> Win95
 
I am using the serial_putchar() and serial_getchar() communication routines on the HandyBoard, and everything is working fine from the PC to the HB. However, I am having trouble getting the HB to send data back to the PC. Here is main() on the HB: (...) (27 years ago, 21-Apr-98, to lugnet.robotics.handyboard)

2 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR