Go to Post Know that CD is a safe environment to learn to talk with a foot in your mouth. - Andrew Schreiber [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #11   Spotlight this post!  
Unread 25-01-2008, 14:25
Kingofl337's Avatar
Kingofl337 Kingofl337 is offline
You didn't see anything....
AKA: Adam
FRC #0501 (Power Knights)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 1998
Location: Manchester, NH
Posts: 861
Kingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond repute
Send a message via Yahoo to Kingofl337
Re: Does reading from the serial port work?

Code:
for ( x = 0 ; byteswaiting == x ; x++ )
This for line contains no magic I just threw this together in a rush. I'm not going to lie to you Alan, while I'm an ok programmer most of what I know has been through trial and error, research PID for instance and web programming html/php/cgi. I just bought a Microchip PIC kit to learn more about the lower lever programming.

In PrintToScreen %d does expect a integer, I've never had a issue using %d with int or char without casting data types. I have have had problems with mixing data types for instance %ld with a int or %d with long.

My function is in main() because that was the only function of the whole program. I wrote it in VEX without a competition template in FRC it's called a Standalone Project in the File menu.

I had a hard time making it work and Brad sent me a program like a year
ago to me and this is how it worked for the most part.

1.) Call GetSerialPort1ByteCount( ) to see if there are any bytes waiting in the buffer.
Code:
 byteswaiting =  GetSerialPort1ByteCount( );
            if ( byteswaiting != 0 )
2.) Create a for loop to empty out the buffer and load it into a array, struct,
or single variable
Code:
for ( x = 0 ; byteswaiting == x ; x++ )
                  {
                        byte = ReadSerialPortOne( );

3.) Do as you will with the data you just received
In this case check for return or print the ASCII code for the keypressed
__________________
FIRST Team 501 PowerKnights - Mentor
FIRST Team 40 Checkmate - Mentor Alum
FIRST Team 146 Blue Lightning - Alumni

Last edited by Kingofl337 : 25-01-2008 at 14:29.
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
No Serial Port G1279 Programming 5 10-01-2008 15:15
Programming the vex microcontroller to respond to commands on the serial port crashoverride02 Programming 1 20-10-2006 14:17
Scripting Setup and the Camera + Serial Port Drivers CJO Programming 22 11-01-2006 17:42
Programming Vex Starter Kit To Recieve From Serial Port firetrap FIRST Tech Challenge 0 26-09-2005 17:27
TTL port to a serial port on a demo board ImmortalAres Programming 16 09-07-2005 23:44


All times are GMT -5. The time now is 22:01.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi