Home \ Help \ Search \ Login RSS

Welcome, Guest. Please Login

This forum is now READ-ONLY! Please visit http://forum.wiring.co/ for the new forum.

Wiring ForumWiring HardwareTangible computing › Serial Buffer Difference?

Page Index Toggle Pages: 1
Serial Buffer Difference? (Read 5319 times)
08/07/08 at 00:33:42

yunkee   Offline
YaBB Newbies
I Love YaBB 2!

Posts: 9
*
 
Is there a difference in buffer sizes for serial on pins 32 and 33 compared to serial1 on pins 3 and 4? I am running the code on my wiring board with two wiring serial monitor windows. One serial monitor is on the USB port (serial on pins 32 and 33) and the other one is monitoring the serial connection on pins 3 and 4 through a DB9 connection. I am able to send values up my set buffer on serial pins 32 and 33 but not on serial pins 3 and 4. I am only able to retrieve the first two bytes being sent. The source code is provided below.




boolean receiveEntry;     //used to check if entry input has been received
int bufIndex;             //buffer index
char buf [5] ;            //buffer for user input
int tempNum;
int tempNum2;



char val;         // variable to receive data from the serial port
int ledpin = 48;  // LED connected to pin 48 (on-board LED)

void setup()
{
 pinMode(ledpin, OUTPUT);  // pin 48 (on-board LED) as OUTPUT
 Serial1.begin(9600);       // start serial communication at 9600bps
 Serial.begin(9600);
}

void loop() {
 Serial.print("Please enter num ");
 while( receiveEntry != true )
 {
   if(Serial.available() > 0 )
   {
     delay(100);
     while( Serial.available() > 0)
     {
       buf[bufIndex] = (char)Serial.read();
       bufIndex++;
     }
     receiveEntry = true;
   }
 }
//store the user input for num
 tempNum = atoi( buf );
//reset variables for next user input
 receiveEntry = false;
 bufIndex = 0;
 for( int i =0; i < sizeof (buf) ; i++ )
 buf[i]  = null;
 Serial.print( '\n' );
 
   Serial.print( "the value of num on serial is ");
 Serial.println( tempNum );
 
 while( receiveEntry != true )
 {
   if(Serial1.available() > 0 )
   {
     delay(100);
     while( Serial1.available() > 0)
     {
       buf[bufIndex] = (char)Serial1.read();
       bufIndex++;
     }
     receiveEntry = true;
   }
 }

 
//store the user input for num2
 tempNum2 = atoi( buf );
//reset variables for next user input

 bufIndex = 0;
 for( int i =0; i < sizeof (buf) ; i++ )
 buf[i]  = null;
 
 Serial.print( "the value of num2 on serial1 is ");
 Serial.println( tempNum2 );
 receiveEntry = false;
}
 
IP Logged
 
Reply #1 - 08/07/08 at 17:42:03

yunkee   Offline
YaBB Newbies
I Love YaBB 2!

Posts: 9
*
 
[quote author=barragan link=1149039993/0#4 date=1149758711]try this:

int valfromserial1;         // variable to receive data
from the serial port
int valfromserial;

void setup()  
{
 Serial.begin(9600);       // serial to Director
 Serial1.begin(9600);       // serial to stepper board
}

void loop() {
 // read from stepperboard & send to computer
 while(Serial1.available()> 0) {  
   valfromserial1 = Serial1.read();  
   Serial.print(valfromserial1, BYTE);  
 }
 // read from computer & send to stepperboard
 while(Serial.available()> 0) {    
   valfromserial = Serial.read();  
   Serial1.print(valfromserial, BYTE);
 }  
 delay(100);  
} [/quote]
It seems like my problem is similar to a previous post. I have tried your code but I am still only getting the first two values being sent from serial1.
 
IP Logged
 
Reply #2 - 08/07/08 at 17:57:37

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
Serial1 is available on pins 2(Rx) and 3(tx) http://wiring.org.co/hardware/index.html#050
 
IP Logged
 
Reply #3 - 08/07/08 at 18:03:41

yunkee   Offline
YaBB Newbies
I Love YaBB 2!

Posts: 9
*
 
barragan wrote on 08/07/08 at 17:57:37:
Serial1 is available on pins 2(Rx) and 3(tx) http://wiring.org.co/hardware/index.html#050

Sorry about that but I did mean pins 2 and 3.
 
IP Logged
 
Reply #4 - 08/08/08 at 15:58:38

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
How are you connecting Serial1 back to your computer? also please le me know OS and Wiring version.
 
IP Logged
 
Reply #5 - 08/13/08 at 14:56:16

yunkee   Offline
YaBB Newbies
I Love YaBB 2!

Posts: 9
*
 
barragan wrote on 08/08/08 at 15:58:38:
How are you connecting Serial1 back to your computer? also please le me know OS and Wiring version.


I am using an MAX233 chip to connect to the wiring board on pins 2 and 3 then it outputs to the computer's serial (DB9) output. Windows XP and Version 2
 
IP Logged
 
Page Index Toggle Pages: 1