Two questions, one quick, the other I have no idea.
1) Returning an array from function call should be done by
pointer reference, yes? So how does one define the function
return type as a pointer. E.g.:
int rates[NUM_CHANNELS];
rates = SPC_getallrates();
//////////////////////////////////////////////////////////
int SPC_getallrates (void)
{
int intensities[NUM_CHANNELS];
int i;
// Do something like record data for .1s and calculate intensities
for (i=0;i<NUM_CHANNELS;i++)
{
intensities[i] = 0;
}
return intensities;
}
2) I'm trying to connect to an RS485 stepper-motor controller via
a standard COM port and a converter cable (supplied with
controller). Sending commands (12 character ASCII strings) to the
controller works fine (movement and status changes occur exactly as
expected), but when a status request is made (another ASCII string),
either the answer is returned in the first 500 characters or not at
all, meaning in order to get a correct response, one has to poll the
controller with the same status request repeatedly. This slows
the response tremendously, as the correct response is only seen once
per 5-10 requests.
I'm currently looping:
FlushInQ(COM_channel);
ComWrt (COM_channel, strQuery, 12);
ComRdTerm (COM_channel, strRead, 500, 13);
FlushInQ(COM_channel);
// Check if certain pattern has been returned.
All ComConfig options (e.g. baud / parity etc. have been set correctly
- or at least, as correctly as I can make out from the minimal
information I have).
OpenComConfig (COM_channel, "COM1", 9600, 0, 8, 1, 4096, 4096);
SetComTime (COM_channel, 0.5);
Any help appreciated.
__________________________________________
The world is full of exciting challenges,
brilliantly disguised as insoluble problems.