Go to Post instead of complaining, suck it up, think a little harder, and make the most of what you do have. - Andy Grady [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
  #1   Spotlight this post!  
Unread 09-09-2003, 19:50
Raven_Writer's Avatar
Raven_Writer Raven_Writer is offline
2004 Detroit & Pittsburgh Winners
AKA: Eric Hansen
FRC #0005 (RoboCards)
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2002
Location: Melvindale
Posts: 1,549
Raven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really nice
Send a message via ICQ to Raven_Writer Send a message via AIM to Raven_Writer Send a message via MSN to Raven_Writer Send a message via Yahoo to Raven_Writer
Sending Data

Ok, I'm almost done w/ my PBASIC Editor, and I'm just wondering...how would you send the code (in MFC)?

I've created a thread, and it doesn't have any problems.

I've been looking at how roboIDE sent the code, and if anyone can just translate these from Linux to Windows I would be set (I don't know any *nux programming):
Code:
read(fd, data, bytes);
I know the "read(...);" function reads the data from a port...but I'm not sure of the equivalent of it in Windows.

Code:
write(fd, data, bytes);
Save as "read(...);"
Code:
close(fd);
I've attempted "CloseHandle(...);", but it throws back a error.
Code:
int openSerial(char *port){
   int fd;
   struct termios tios;

   fd=open(port, O_NOCTTY | O_RDWR | O_NONBLOCK);
   if(fd<0){
     sprintf(lastError, "%s: %s\n", port, strerror(errno));
     return fd;
   }

   bzero(&tios, sizeof(termios));

   tios.c_cflag = BAUDRATE | CS8 | CREAD;
   tios.c_iflag = IGNPAR;
   tios.c_oflag=0;

   tios.c_lflag=0;

   //satisfy read immediately.
   tios.c_cc[VTIME]=0;
   tios.c_cc[VMIN]=0;

   tcflush(fd, TCIFLUSH);
   tcsetattr(fd, TCSANOW, &tios);

   return fd;
}
<<EDIT>>: I know fd stands for file directive (I think anyways).
__________________
AIM: wisprmylastbreth
EMail: nightskywriter@gmail.com
Y!: synsoflife

"ai yoru ga" -- "Love the nights"
  #2   Spotlight this post!  
Unread 09-09-2003, 21:51
Brandon Martus's Avatar Unsung FIRST Hero
Brandon Martus Brandon Martus is offline
busy.
AKA: B. Slash Kamen
no team
 
Join Date: May 2001
Rookie Year: 1998
Location: Nevada, TX USA
Posts: 5,271
Brandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond repute
Send a message via ICQ to Brandon Martus Send a message via AIM to Brandon Martus Send a message via Yahoo to Brandon Martus
Re: Sending Data

Quote:
Originally posted by Raven_Writer
<<EDIT>>: I know fd stands for file directive (I think anyways).
File Descriptor. I can't help with your actual question, though, .. sorry
__________________
Brandon Martus
e-mail
  #3   Spotlight this post!  
Unread 10-09-2003, 13:11
Raven_Writer's Avatar
Raven_Writer Raven_Writer is offline
2004 Detroit & Pittsburgh Winners
AKA: Eric Hansen
FRC #0005 (RoboCards)
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2002
Location: Melvindale
Posts: 1,549
Raven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really nice
Send a message via ICQ to Raven_Writer Send a message via AIM to Raven_Writer Send a message via MSN to Raven_Writer Send a message via Yahoo to Raven_Writer
Re: Re: Sending Data

Quote:
Originally posted by Brandon Martus
File Descriptor. I can't help with your actual question, though, .. sorry
Thanks Brandon I talked to Rob last night, and now I only need help on the last code section. read() = ReadFile(), write() = WriteFile().

<< Edit >>: The stuff below bolded is what I don't get:
Code:
int openSerial(char *port){
   struct termios tios;

   fd=open(port, O_NOCTTY | O_RDWR | O_NONBLOCK);
   if(fd<0){
     sprintf(lastError, "%s: %s\n", port, strerror(errno));
     return fd;
   }

   tios.c_cflag = BAUDRATE | CS8 | CREAD;
   tios.c_iflag = IGNPAR;
   tios.c_oflag=0;

   tios.c_lflag=0;

   //satisfy read immediately.
   tios.c_cc[VTIME]=0;
   tios.c_cc[VMIN]=0;

   tcflush(fd, TCIFLUSH);
   tcsetattr(fd, TCSANOW, &tios);

   return fd;
}
__________________
AIM: wisprmylastbreth
EMail: nightskywriter@gmail.com
Y!: synsoflife

"ai yoru ga" -- "Love the nights"

Last edited by Raven_Writer : 10-09-2003 at 16:02.
  #4   Spotlight this post!  
Unread 10-09-2003, 16: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
You're trying to mix POSIX and Win32. The two are NOT compatible and probably never will be, knowing MS. Instead, I'd recomend you grab code snippets out of RoboGUI, as it also has the ability to tokenize and send directly to the RC.

-Rob
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #5   Spotlight this post!  
Unread 10-09-2003, 16:41
Raven_Writer's Avatar
Raven_Writer Raven_Writer is offline
2004 Detroit & Pittsburgh Winners
AKA: Eric Hansen
FRC #0005 (RoboCards)
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2002
Location: Melvindale
Posts: 1,549
Raven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really nice
Send a message via ICQ to Raven_Writer Send a message via AIM to Raven_Writer Send a message via MSN to Raven_Writer Send a message via Yahoo to Raven_Writer
Quote:
Originally posted by rbayer
You're trying to mix POSIX and Win32. The two are NOT compatible and probably never will be, knowing MS. Instead, I'd recomend you grab code snippets out of RoboGUI, as it also has the ability to tokenize and send directly to the RC.

-Rob
Ok, thanks. I've been able to get most of the code to compile without error though (not been able to actually send though, not tested that far). I've been looking through both RoboGUI and RoboEMU, and RoboGUI I thought had some sending code (and apperently I'm right, woo hoo!).

Again, thanks.
__________________
AIM: wisprmylastbreth
EMail: nightskywriter@gmail.com
Y!: synsoflife

"ai yoru ga" -- "Love the nights"
  #6   Spotlight this post!  
Unread 10-09-2003, 22:48
Rickertsen2 Rickertsen2 is offline
Umm Errr...
None #1139 (Chamblee Gear Grinders)
Team Role: Alumni
 
Join Date: Dec 2002
Rookie Year: 2002
Location: ATL
Posts: 1,421
Rickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant future
Send a message via AIM to Rickertsen2 Send a message via Yahoo to Rickertsen2
If i remember correctly, there is an MSDN article on serial port communications, with code samples.

<edit>
or maybie not. I can't seem to find the article. I know im not crazy. Im pretty sure i saw it at one time or another.
</edit>
__________________
1139 Alumni

Last edited by Rickertsen2 : 10-09-2003 at 23:18.
  #7   Spotlight this post!  
Unread 11-09-2003, 14:46
Raven_Writer's Avatar
Raven_Writer Raven_Writer is offline
2004 Detroit & Pittsburgh Winners
AKA: Eric Hansen
FRC #0005 (RoboCards)
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2002
Location: Melvindale
Posts: 1,549
Raven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really nice
Send a message via ICQ to Raven_Writer Send a message via AIM to Raven_Writer Send a message via MSN to Raven_Writer Send a message via Yahoo to Raven_Writer
I've got my program 99.9% running without problems. Only problem I'm having right now is having it not close when it cannot connect/send data to a specific port.

If you would like to see my code for it (it'll be a big thing to post on CD), IM, PM, or e-mail me.
__________________
AIM: wisprmylastbreth
EMail: nightskywriter@gmail.com
Y!: synsoflife

"ai yoru ga" -- "Love the nights"
  #8   Spotlight this post!  
Unread 11-09-2003, 16:05
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
Umm... more details, please. What is/isn't closing that shouldn't/should be? Are you talking about the file handle? Or the program itself.
/me=
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #9   Spotlight this post!  
Unread 11-09-2003, 16:28
Raven_Writer's Avatar
Raven_Writer Raven_Writer is offline
2004 Detroit & Pittsburgh Winners
AKA: Eric Hansen
FRC #0005 (RoboCards)
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2002
Location: Melvindale
Posts: 1,549
Raven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really nice
Send a message via ICQ to Raven_Writer Send a message via AIM to Raven_Writer Send a message via MSN to Raven_Writer Send a message via Yahoo to Raven_Writer
Quote:
Originally posted by rbayer
Umm... more details, please. What is/isn't closing that shouldn't/should be? Are you talking about the file handle? Or the program itself.
/me=
Sorry. Here's what happens:

I open a file that has the default code for v2 of PBASIC that Innovation First supplied us, and goto Run->Download (which downloads the code). When I do that, what happens is that it shows two message boxes saying "Error getting serial port status" (which I can pin-point where the main problem seems to be). Then after I click OK twice (once for each message box), the program itself closes.

(I know this may be a bunch of wasted typing, but I hope that it clears it up as much as possible)
__________________
AIM: wisprmylastbreth
EMail: nightskywriter@gmail.com
Y!: synsoflife

"ai yoru ga" -- "Love the nights"
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
Competition Scouting pauluffel Scouting 31 09-01-2003 00:34
Robot Scouting Database archiver 2001 10 24-06-2002 03:00
Limiting PWM in pbasic archiver 2001 4 24-06-2002 00:38
Possible Configuration to keep things cheap archiver 1999 8 23-06-2002 23:03
Distribution of data soap108 Scouting 4 24-12-2001 09:23


All times are GMT -5. The time now is 09:38.

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