client static real SacarPesoBascula(str puerto)
{
System.IO.Ports.SerialPort test = new System.IO.Ports.SerialPort();
str dataBack;
int rei=10;
int i=0;
;
try
{
test.set_PortName(puerto);
test.set_BaudRate(1200);
test.set_Parity(System.IO.Ports.Parity::None);
test.set_DataBits(8);
//test.set
test.Open();
test.WriteLine("$");
for(i=0;i<=10;i++)
{
sleep(1000);
dataBack = test.ReadExisting();
if(dataBack!="")
{
break;
}
sleep(1000);
}
test.Close();
return str2num(dataBack);
}
catch
{
info("error");
return 0;
}
return 0;
}
Hi fren,
ResponderEliminari tried your code & make it run with AT command. but somehow, the AX job cannot send SMS. however, it successfully send SMS if i'm using hyperterminal. Any comment?
this is my code :
System.IO.Ports.SerialPort test = new System.IO.Ports.SerialPort();
str dataBack;
int rei=10;
int i=0;
str _command;
;
try
{
test.set_PortName("COM4");
test.set_BaudRate(115200);
test.set_Parity(System.IO.Ports.Parity::None);
test.set_DataBits(8);
test.Open();
test.WriteLine("AT" + "\x001a");
test.WriteLine("AT+CMGF=1" + "\x001a");
_command = "AT+CMGS=\\" + "'0133409936'" + "\\" + "\\r";
test.WriteLine(_command);
test.WriteLine("TEST" + "\x001a");
for(i=0;i<=10;i++)
{
sleep(1000);
dataBack = test.ReadExisting();
if(dataBack!="")
{
break;
}
sleep(1000);
}
test.Close();
}
catch
{
info("error");
}