View Single Post
  #6   Spotlight this post!  
Unread 08-02-2012, 14:51
wireties's Avatar
wireties wireties is offline
Principal Engineer
AKA: Keith Buchanan
FRC #1296 (Full Metal Jackets)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Rockwall, TX
Posts: 1,170
wireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond repute
Send a message via AIM to wireties
Re: Usage of serial port on cRio

Quote:
Originally Posted by mikets View Post
I don't have Wind River in front of me at the moment so I can't verify the com class especially the Read method, but my instinct tells me that you declare buffer as a "char *" which means there is no buffer associated with it. buffer is an uninitialized pointer. If the Read method is going to put bytes into buffer, it is going to trash random memory locations.

I could be wrong

Nope, you are 100% correct. They have declared/reserved no storage. Change char *buffer to char buffer[X] where X is big enough to hold the data. It should work then but it is a bit of a kludge, you probably want a bigger buffer declared as a global or allocate the memory so it is not on the stack (as all local variables are).

HTH
__________________
Fast, cheap or working - pick any two!

Last edited by wireties : 08-02-2012 at 15:06.
Reply With Quote