Subject:
|
Re: Serial Communication %!*#!!--Please Help
|
Newsgroups:
|
lugnet.robotics.handyboard
|
Date:
|
Wed, 18 Nov 1998 12:51:25 GMT
|
Original-From:
|
Fred G. Martin <fredm@+avoidspam+media.mit.edu>
|
Viewed:
|
1841 times
|
| |
| |
Hi Peter,
There was recently a discussion on the list where it was revealed that
the network style cable does NOT work to connect to HB's together.
If you go back to the FAQ there will now be correct instructions for
making a cable to link two HBs.
Fred
In your message you said:
> I need for two HBs to communicate via the serial port. I'm using the "networ
k" style cable. With Randy Seargent's serialio routines and the code that is in
the HB FAQ. Please Help my project is due the Monday after Thanksgiving. Any
input would be greatly appreciated.
> Thanks
> Peter
>
> This is the code on the transmitting HB: (basically the code in the FAQ)
> void serial_putchar(int c)
> {
> while (!(peek(0x102e) & 0x80)); /* wait until serial transmit empty */
> poke(0x102f, c); /* send character */
> }
>
> void printdec(int n)
> {
> int leading_digit= 0;
> int dig, div;
>
> if (n == 0) {
> _printnum(0);
> return;
> }
>
> if (n < 0) {
> serial_putchar('-');
> n = 0 - n;
> }
>
> for (div= 10000; div= div/10; div> 0) {
> dig= n/div;
> n= n - dig*div;
> if (dig || leading_digit) {
> _printnum(dig);
> leading_digit= 1;
> }
> }
> }
>
> /* prints digit from 0 to 9 over serial line */
> void _printnum(int n)
> {
> serial_putchar(n + '0');
> }
>
> /*To start a new line on the serial output, use:*/
>
> void newline() {
> serial_putchar(10);
> serial_putchar(13);
> }
>
> void main(){
> newline();
> while(1){
> printdec(5);
> }
> }
>
> This is the code on the recieving HB:
> 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 aga in */
> {
> poke(0x3c, 0);
> }
>
> int serial_getchar()
> {
> while (!(peek(0x102e) & 0x20)); /* wait for received character */
> return peek(0x102f);
> }
>
> int main(){
> disable_pcode_serial();
> while(1){
> printf("\n%d", serial_getchar());
> sleep(.05);
> }
> }
>
>
>
>
> ----------------------------------------------------------------------------- ----------------------
> Peter Eacmen
> Boston Latin School
> babylongod@usa.net
>
> Knowledge is power,
> power is money,
> knowledge is money!
>
>
|
|
Message is in Reply To:
| | Serial Communication %!*#!!--Please Help
|
| I need for two HBs to communicate via the serial port. I'm using the "network" style cable. With Randy Seargent's serialio routines and the code that is in the HB FAQ. Please Help my project is due the Monday after Thanksgiving. Any input would be (...) (26 years ago, 18-Nov-98, to lugnet.robotics.handyboard)
|
2 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|