Subject:
|
Serial Communication %!*#!!--Please Help
|
Newsgroups:
|
lugnet.robotics.handyboard
|
Date:
|
Wed, 18 Nov 1998 01:56:17 GMT
|
Original-From:
|
Peter Eacmen <[eacmen@postoffice.worldnet.]Spamless[att.net]>
|
Viewed:
|
2681 times
|
| |
 | |
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 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 again */
{
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 has 1 Reply:  | | Re: Serial Communication %!*#!!--Please Help
|
| 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. (...) (27 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
|
|
|
|