Login  
Search All Forums
Dart Home | PowerTCP Telnet for .NET | Custom Development Reply | PowerTCP Telnet for .NET Topics | Forums   
AuthorForum: PowerTCP Telnet for .NET
Topic: Reading Data from a Chamber's controller
xplorer2k

From: Oxnard, CA USA
Posts: 33
Member Since: 03/27/09
posted June 14, 2009 10:22 PM

Hi Everyone,

I am running temperature cycling and I need to get the temperature reading
from the chamber. The chamber's controller sends the data that needs
to be converted using the following code:


//Receive response
len = s.Receive(received);

//Convert received ASCII bytes to string
temp = ASCIIEncoding.ASCII.GetString(received, 0, len);

string tempVar = "";

//remove last two non-printable characters from string "temp"
for (int i = 0; i < temp.Length - 2; i++)
tempVar += temp[i].ToString();

xVar = tempVar;
tempReadingX = Convert.ToDouble(xVar);


//Close socket
s.Close();

return tempReadingX;

How do I read and convert the data using the
telnet.Marshal(telnet.Read("Password"), null) command?

Thanks,

xplorer2k



xplorer2k

From: Oxnard, CA USA
Posts: 33
Member Since: 03/27/09
posted June 15, 2009 7:28 PM

When I read data from chamber's controller I get a single digit "3" displayed at textDisplay textbox (when the actual temperature is 40.0 degree C).

How do I convert this data to a double type after using the "telnet.Marshal(telnet.Read(""), null)" command?

Thanks,
xplorer2k
Jason Farrar (Admin)

From: Oneida, NY USA
Posts: 223
Member Since: 07/24/07

Extra Support Options
Custom Application Development

posted June 16, 2009 10:28 AM

Hi,

 When you use the Marshal method the data is sent back to the UI thread as a byte array. To convert it to a double you could do:

double temp = double.parse(e.Data.ToString());

 You would put this code in the Data event on the UI thread.

 Also, I'm not sure you want to be using Telnet.Read(""), that overload of the read method takes a delimiter and you are sending in and empty string as the delimiter. I'm not sure what, if any, effect that may have on reading the bytes over the connection.
xplorer2k

From: Oxnard, CA USA
Posts: 33
Member Since: 03/27/09
posted June 17, 2009 8:00 PM

Thanks Jason,

I need to use "telnet.Marshal(telnet.Read(""), null)" as the controller sends just numeric data and can be any number (type double). Is there any other approach that I could use?.

Thanks again,
xplorer2k
Reply | PowerTCP Telnet for .NET Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX