|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||||
|
|||||
|
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); Code:
write(fd, data, bytes); Code:
close(fd); 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;
}
|
|
#2
|
|||||
|
|||||
|
Re: Sending Data
Quote:
|
|
#3
|
|||||
|
|||||
|
Re: Re: Sending Data
Quote:
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;
}
Last edited by Raven_Writer : 10-09-2003 at 16:02. |
|
#4
|
||||||
|
||||||
|
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 |
|
#5
|
|||||
|
|||||
|
Quote:
Again, thanks. |
|
#6
|
||||
|
||||
|
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> Last edited by Rickertsen2 : 10-09-2003 at 23:18. |
|
#7
|
|||||
|
|||||
|
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. |
|
#8
|
||||||
|
||||||
|
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= ![]() |
|
#9
|
|||||
|
|||||
|
Quote:
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) |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |