LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

SinPattern error

ok, so i left string size, but i still get SinPattern error that number of samples must be >0.

 

hmm..

0 Kudos
Message 11 of 17
(968 Views)

anyone can help?

0 Kudos
Message 12 of 17
(950 Views)

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:

  1. That the string is well formatted
  2. That ComWrt does not return any error (bytes_sent must be > 0)

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:

  1. That ComRdTerm does not return any error
  2. That the received string is the one you sent
  3. That Scan instruction does return the correct values

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.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 13 of 17
(947 Views)

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;
}

 

0 Kudos
Message 14 of 17
(940 Views)

Finally solved the problem, it was a foolish mistake at defined stopbits. Than you for all you help.

0 Kudos
Message 15 of 17
(931 Views)

Got one last question, with what function can i clean graph?

0 Kudos
Message 16 of 17
(928 Views)

please delete few top my posts, i found everything what i need.

0 Kudos
Message 17 of 17
(926 Views)