Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Does reading from the serial port work? (http://www.chiefdelphi.com/forums/showthread.php?t=62326)

Kingofl337 28-01-2008 16:06

Re: Does reading from the serial port work?
 
1 Attachment(s)
So, everyone knows I screwed up on this one by rushing. It shows what happens with a "QUICK" fix. My mistake here was my own and not a reflection on intelitek or as we don't even support WPILIB functions that are not in the tree.

My orginal For Loop was:
Code:

for ( x = byteswaiting ; byteswaiting == x ; x++)
While this printed a byte at a time it was only by shear luck. After Alan made a comment I quickly changed it to:

Code:

for ( x = 0 ; byteswaiting == x ; x++)
I was not trying to hide anything as it says in chief I have edited the post. The trouble is this doesn't work either hence Alan's frustration. I just didn't see it and didn't test this "QUICK" fix.

Now having had time to look at it again. I saw my problem and have fixed
it. This version will accept 4 keystrokes "bytes" and then print them to screen. Please let me know if you see an issue. The function must be call
in a while loop and added to userincludes.h.

Chris_Elston 29-01-2008 07:15

Re: Does reading from the serial port work?
 
Quote:

Originally Posted by Alan Anderson (Post 686370)
I tried the example code provided, and never saw GetSerialPort1ByteCount( ) return a nonzero value. I ran equivalent code that I wrote and compiled using MPLab, and it worked exactly as I expected.

I'm done with EasyC. I can't do what I want using it.

Well if it's any consolation, one of my students was trying to interface a custom vision board using EasyC and we've been following this thread. We've got ours working last night. We used an example C File, customized it some from a vendor and managed to read bytes coming from the custom camera controller. We'll let me correct that, my student manage to get it to work, not "we". He is using the TTL rs-232 port on the RC to a DB-9 port on the camera board. So far all is well.

EasyC has been good to us, sorry it hasn't worked out so good for you. However knowing you Alan, I can understand you'd like more freedom in coding your custom code. Our programming team has found Mr. Millers WPILIB pdf handy, we've read it through and through and understand what built in functions we can use. We've tried to use what is available. Our custom RS-232 interface parser was the first time we added our own C File to EasyC, and included it for compile. Doing it this way, gave the "old" school feel and allowed for the flexibility of customized functions we needed to create to interface to the vision board. Maybe you can take the same approach. Write your own custom C Files outside EasyC in notepad or I prefer NotePad + +, and include your header files etc, but allow the C Code blocks for your beginner programs and let yourself and advance programmers code in the C File with custom functions.

Of course there will be some overhead as if you’re doing your own functions you’re not using utilizing the WPILIB.

Anyway, I just wanted to give our perspective on EasyC. I am sure we could share what we have, but I'll have to check with Nathan first if he wants to allow it now (week 3 in build season). Nathan: our master programmer, which BTY, I am in dear now to chant "Nathan is the man", a young bright home schooler I hope you can chat with some day.

Chris - THRUST : 1501 : Huntington, Indiana


All times are GMT -5. The time now is 16:12.

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