12-17-2011 11:55 AM
ok, so i left string size, but i still get SinPattern error that number of samples must be >0.
hmm..
12-18-2011 06:36 AM
anyone can help?
12-18-2011 07:07 AM - edited 12-18-2011 07:11 AM
Hello A Z,
are you investigating on this error or are you simply asking the forum? Have you tried any debug action? If I were you I'd try looking at the parameters sent to SinePattern function: if any of them is wrong I'd go back looking at the message recevied on the RS232 and back again to the message sent if needed!
Now, this is what you have to do to go out of this trap:
Place a breakpoint in SendGraph and check:
Note that if you want to use ComRdTerm in Gavimas, you must append the termination character to the string! (and you never did it in all the code you posted).
Next place a breakpoint in Gavimas and check:
The most probable thing is that ComRdTerm is ending with a timeout error (-99) since it does not find any termination character: you should always add error checking on critical functions to be warned about abnormal situations.
Error checking is very important in any application, but particularly when you deal with external devices and serial communications, as several problems can arise in communicating over this channel and you must appropriately handle all of them.
12-18-2011 08:36 AM
i found that i get these digits:
numpoints after reading from comport becomes 0
sig1amp2 =9.462845012544626E-308
sig1phase2=2.248947294617687E-318
and cycles2=2.204819833261512E-307
so it reads, but numbers are a mess and why numpoints becomes 0?
heres my code:
void SendGraph (void)
{
char ch[100];
sprintf (ch, "%.3f; %.3f; %d; %.1f", sig1amp, sig1phase, numpoints, cycles);
//Writes output to the specified string according to format specifiers in formatString.
//A null character is written at the end of the characters written.
strcat(ch, "\r");
// Appends a copy of a source string to the end of a target string, including the terminating ASCII NUL byte.
// The initial character of the string to append overwrites the NUL byte at the end of the target string.
// If copying takes place between objects that overlap, the behavior is undefined.
stringsize = StringLength (ch);
bytes_sent = ComWrt (comport, ch, stringsize);
}
/*---------------------------------------------------------------------------*/
/* Gauti grafika */
/*---------------------------------------------------------------------------*/
int CVICALLBACK Gavimas (int panel, int control, int event,
void *callbackData, int eventData1,
int eventData2)
{
double wave2[2048];
int numpoints2;
double sig1amp2;
double sig1phase2;
double cycles2;
switch (event)
{
case EVENT_COMMIT:
read_data[0] = '\0';
read_term = 13;
if (read_term)
bytes_read = ComRdTerm (comport, read_data, read_cnt, read_term);
Scan (read_data, "%f[x]%f[x]%d[x]%f[x]", &sig1amp2, &sig1phase2, &numpoints2, &cycles2);
SinePattern(numpoints2,sig1amp2,sig1phase2,cycles2,wave2);
/* Update UIR */
DeleteGraphPlot (mainpnl, MAINPNL_SIGGRAPH_2, -1, VAL_DELAYED_DRAW);
plot2 = PlotY (mainpnl, MAINPNL_SIGGRAPH_2, wave2, numpoints2,
VAL_DOUBLE, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID,1, VAL_WHITE);
RS232Error = ReturnRS232Err ();
if (RS232Error)
DisplayRS232Error ();
break;
case EVENT_RIGHT_CLICK :
break;
}
return 0;
}
12-18-2011 11:09 AM - edited 12-18-2011 11:10 AM
Finally solved the problem, it was a foolish mistake at defined stopbits. Than you for all you help.
12-18-2011 11:30 AM
Got one last question, with what function can i clean graph?
12-18-2011 11:42 AM
please delete few top my posts, i found everything what i need.