Go to Post I hate you.... in a graciously professional sort of way. - Uberbots [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

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #61   Spotlight this post!  
Unread 10-06-2002, 19:16
Ian W. Ian W. is offline
College? What?
no team (Gompei and the Herd)
Team Role: College Student
 
Join Date: Jan 2002
Rookie Year: 2002
Location: Worcester, MA | Smithtown, NY
Posts: 1,464
Ian W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to all
Send a message via AIM to Ian W.
bah, that doesn't work, but i have one idea. is there a way that i can say that if getch () is 0, then virtually press the enter key? i know you can do the keyboard part, not sure how though. but if i had it constantly 'press' enter, unless i hit a button, in which case it stops. i think that would work, not sure though.
__________________
AIM --> Woloi
Email --> ian@woloschin.com
  #62   Spotlight this post!  
Unread 10-06-2002, 19:41
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
What's not working? Have you tried the code I posted earlier? Make sure to check kbdhit() before you call getch(). That seems to work on my computer.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #63   Spotlight this post!  
Unread 10-06-2002, 20:08
Ian W. Ian W. is offline
College? What?
no team (Gompei and the Herd)
Team Role: College Student
 
Join Date: Jan 2002
Rookie Year: 2002
Location: Worcester, MA | Smithtown, NY
Posts: 1,464
Ian W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to all
Send a message via AIM to Ian W.
yeah, i'm going to go and smack myself. i forgot kbhit (), so it kinda doesn't work . i feel so stupid now...

oh well, at least i know what i'm doing now.
__________________
AIM --> Woloi
Email --> ian@woloschin.com
  #64   Spotlight this post!  
Unread 12-06-2002, 21:54
Ian W. Ian W. is offline
College? What?
no team (Gompei and the Herd)
Team Role: College Student
 
Join Date: Jan 2002
Rookie Year: 2002
Location: Worcester, MA | Smithtown, NY
Posts: 1,464
Ian W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to all
Send a message via AIM to Ian W.
ok, i have my serial communications program working, or at least i think so. there's one part i'm not sure of, which is as follows...

Code:
if(!ReadFile(hSerial, szBuff, 26, &dwBytesRead, NULL))	{
           //error reading serial port. Process appropriately.
	cout << "Uh oh" << endl;
}
the little 'uh oh' was just a phrase i spat out to test where the program was failing. it seems to be able to get up to this statement, and then it freezes. i'm assuming this is because i don't have the robot hooked up to it, but i just want to be sure. i'm going to be testing it tomorrow, i think, so i can be sure about whether or not it works, but i just want to make sure that this line of code (or lines) will work correctly, which it should. if this code works, i think i have the basic program all done, and all i need to do is 'customize' the dashboard, so i can change the numbers to reflect this year's robot program. but i want to make sure the actual basic program works first.
__________________
AIM --> Woloi
Email --> ian@woloschin.com
  #65   Spotlight this post!  
Unread 12-06-2002, 22:04
Ian W. Ian W. is offline
College? What?
no team (Gompei and the Herd)
Team Role: College Student
 
Join Date: Jan 2002
Rookie Year: 2002
Location: Worcester, MA | Smithtown, NY
Posts: 1,464
Ian W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to all
Send a message via AIM to Ian W.
most interesting, as i was trying out the different COM ports (when you initially open the port, the "COM#" line), and when i did COM3, it worked as it should. i'm assuming that means that my computer is set to COM3 and COM4, but i have no idea how that works. so, it appears that my program is working as it's supposed to after all...

one thing though. does a COM port without a incoming signal transmit '-52' out, cause that seems to be what i'm reading... :/
__________________
AIM --> Woloi
Email --> ian@woloschin.com
  #66   Spotlight this post!  
Unread 12-06-2002, 23:39
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
In theory, you shouldn't read anything without a device connected; the ReadFile should hang the thread. The easiest way to figure out what COM ports you have is to open up your device manager and look under the Ports category.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #67   Spotlight this post!  
Unread 13-06-2002, 09:14
Unsung FIRST Hero
Matt Leese Matt Leese is offline
Been-In-FIRST-Too-Long
FRC #1438 (The Aztechs)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1998
Location: Long Beach, CA
Posts: 937
Matt Leese has a reputation beyond reputeMatt Leese has a reputation beyond reputeMatt Leese has a reputation beyond reputeMatt Leese has a reputation beyond reputeMatt Leese has a reputation beyond reputeMatt Leese has a reputation beyond reputeMatt Leese has a reputation beyond reputeMatt Leese has a reputation beyond reputeMatt Leese has a reputation beyond reputeMatt Leese has a reputation beyond reputeMatt Leese has a reputation beyond repute
Send a message via AIM to Matt Leese
It seems very strange that your computer is setup to use COM3 and 4. I've never seen that. Normally a computer is setup so that the serial port is COM1 and the modem as COM2 (or vice-versa; modems have hardware, called a UART, so that they are treated exactly the same as a serial port). I would suspect that for whatever reason windows is actually letting you open COM3 even though it's not really connected to anything (the open command should fail at that point). I'd also check to make sure that your modem isn't on COM3 (as you should be able to open that). Just as an fyi, 51 is 0x33 and -51 would then be 0xCD which isn't any sort of code that I know. Anyone know any different?

Matt
  #68   Spotlight this post!  
Unread 13-06-2002, 14:34
Ian W. Ian W. is offline
College? What?
no team (Gompei and the Herd)
Team Role: College Student
 
Join Date: Jan 2002
Rookie Year: 2002
Location: Worcester, MA | Smithtown, NY
Posts: 1,464
Ian W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to all
Send a message via AIM to Ian W.
ok, i figured it out. sorry for the confusion, but i was rather confused last night too .

anyways, i realized after that the reason it worked when i opened it on COM3 or 4, was that everything just failed, and because my program is bare basics, it would still continue (yeah, i have to fix that part ). anyways, it would just jump into the loop, and get stuck. of course, i didn't realize it, but now it all makes sense. so, that problem is fixed.

the other part, about it not working on 1 and 2, is exactly what rbayer said. the read file thread hung up the program, cause there was nothing hooked up (this was at home). today in school, i tried to run the program, but realized i had completely screwed up the array that collected the data, because i'm stupid . so, i fixed that, and waiting till tomorrow to test it.

also, in a stroke of luck, i'm taking the robot home for the summer, so i can keep working on it . looks like i'm not going to die if rbayer doesn't get that PBASIC emulator thing out right away . keep working on it though, cause it's a really good idea, especially for at competition, when you usually want to test the code before you use it.
__________________
AIM --> Woloi
Email --> ian@woloschin.com
  #69   Spotlight this post!  
Unread 13-06-2002, 14:50
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
Quote:
Originally posted by Ian W.
looks like i'm not going to die if rbayer doesn't get that PBASIC emulator thing out right away . keep working on it though, cause it's a really good idea, especially for at competition, when you usually want to test the code before you use it.
Have no fear! School is out and I have nothing better to do for the next month. It will be done, I just don't know when.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #70   Spotlight this post!  
Unread 13-06-2002, 15:00
Ian W. Ian W. is offline
College? What?
no team (Gompei and the Herd)
Team Role: College Student
 
Join Date: Jan 2002
Rookie Year: 2002
Location: Worcester, MA | Smithtown, NY
Posts: 1,464
Ian W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to all
Send a message via AIM to Ian W.
heh, one more day of classes for me...then a week of regents . but, i'll have plenty of time after to make some good flash/c++ program, and to fix up the robot. can't wait...
__________________
AIM --> Woloi
Email --> ian@woloschin.com
  #71   Spotlight this post!  
Unread 13-06-2002, 16:48
Ian W. Ian W. is offline
College? What?
no team (Gompei and the Herd)
Team Role: College Student
 
Join Date: Jan 2002
Rookie Year: 2002
Location: Worcester, MA | Smithtown, NY
Posts: 1,464
Ian W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to all
Send a message via AIM to Ian W.
hmm, quick question...

when i had my buggy C++ dashboard port reader running today, i had accedentally set it only to fout (file out) the first byte (yes, very stupid mistake on my part ). anyways, in Dan's little 'byteviewer' flash program, it came up as various numbers, like 80, 40, -52, etc. i was under the impression that the first two bytes were 0xff, or 255. what's the deal with this?
__________________
AIM --> Woloi
Email --> ian@woloschin.com
  #72   Spotlight this post!  
Unread 13-06-2002, 17:43
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
The problem is, there is nothing to guarantee that you will start reading at the beginning of a packet. That is why you have to read in 26 bytes, find the beginning, and then start processing from there.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #73   Spotlight this post!  
Unread 13-06-2002, 18:40
Ian W. Ian W. is offline
College? What?
no team (Gompei and the Herd)
Team Role: College Student
 
Join Date: Jan 2002
Rookie Year: 2002
Location: Worcester, MA | Smithtown, NY
Posts: 1,464
Ian W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to all
Send a message via AIM to Ian W.
ah, ok that makes sense. so, i do a first read, finding the double 255/0xff, and then once i find that, start the main loop? i think i know how that should work, although not completely sure.
__________________
AIM --> Woloi
Email --> ian@woloschin.com
  #74   Spotlight this post!  
Unread 13-06-2002, 20:23
DanL DanL is offline
Crusty Mentor
FRC #0097
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: Somerville, MA
Posts: 682
DanL is just really niceDanL is just really niceDanL is just really niceDanL is just really niceDanL is just really nice
Send a message via AIM to DanL
Okay, so this part sure is the painful part... after about an hour discussing it, Ian and I decided to do something, just we wanna know if this is the 'correct' way of doing it...

Basically we're going to read in one byte at a time to a fixed queue of 28 positions. When the first two items and last two items are equal to 255, then we know that we have a full packet, and we read the queue for the appropriate information. If all four items aren't equal to 255, then we know we don't have a full packet, and we just continue adding to the queue.

For a visualization (they're easier to understand), I made a simple visualized version of what we're going to do... http://24.186.144.31:81/queue-visual/moo.html

I believe this is going to work, but if it doesn't, how are you supposed to parse the bytes, or, determine where a packet begins?
__________________
Dan L
Team 97 Mentor
Software Engineer, Vecna Technologies
  #75   Spotlight this post!  
Unread 13-06-2002, 20:24
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
I'd avoid reading one byte at a time if possible. It is inefficient and means your program will loop more often. And if you miss a byte, the output could appear sluggish or delayed. If you want to do something similar to this, I'd recommend that that you just discard data until you find a 255,255 and then copy the next 24 bytes into your data structure.

Quote:
Originally posted by Ian W.
ah, ok that makes sense. so, i do a first read, finding the double 255/0xff, and then once i find that, start the main loop? i think i know how that should work, although not completely sure.
Everytime through the loop you should resort the data. Otherwise, if you miss even a single bit, the whole packet will be off and the data won't make any sense. My advice is to read the data into a temporary storage space and then sort it into a final one. That's the way I did it in my dashboard program, and it works fairly well. If you want to take a look, the source is at http://FIRSTprograms.tripod.com under the name gDash. Or, I can send you just the relevant portion of code if you would prefer.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php

Last edited by rbayer : 13-06-2002 at 20:30.
Closed Thread


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
Win32 serial port - recieve buffer seanwitte Programming 4 05-11-2003 21:41
White Paper Discuss: FIRST Editor v1.2 CD47-Bot Extra Discussion 1 18-09-2003 19:32
How to communicate both through radio and serial port? JC Denton Programming 1 08-02-2003 23:43
Ever seen this serial port problem before??? Aidan F. Browne Programming 5 05-02-2003 12:03
serial communication using c++ Malakili Programming 31 01-05-2002 15:51


All times are GMT -5. The time now is 10:32.

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