Can we convert type by int8(*) in script ?

Discuss issues and ideas you have to configuring displays with PowerVision
TimTian
Posts: 22
Joined: Wed Sep 25, 2013 10:26 pm

Can we convert type by int8(*) in script ?

Post by TimTian » Wed Nov 13, 2013 3:46 am

Hi All,

I find that I can't use int8(*) to convert the raw type to int8. Pls see below:

int8 Angle_int;
smRead(VariableIDs.Angle, Angle_int); //////////////////VariablesIDs.Angle from can.
smWrite(VariableIDs.MedVariable, Angle_int);
processScreenApi();


The result of MedVariable is not correct!

Is there anyone can help me out?
ksaenz
Enovation Controls Development
Enovation Controls Development
Posts: 263
Joined: Thu Aug 19, 2010 7:53 am

Re: Can we convert type by int8(*) in script ?

Post by ksaenz » Wed Nov 13, 2013 11:38 am

Hello TimTian,

You can try this functions to convert betweend signed and unsigned variables:

Code: Select all

double utos( double x )
{
	uint16 u;
	int16 s;	

	u = x;
	s = u & 0xFFFF;
	x = s;	

	return x;
}

double stou( double x )
{
	uint16 u;
	int16 s;	

	s = x;
	u = s & 0xFFFF;
	x = u;	

	return x;
}
Regards,
ksaenz