Jump to content
OMRON Forums

Getting several values with GetResponseEx


TSV
 Share

Recommended Posts

I use GetResponseEx function in my C# app to get values from Clipper board.

 

But when I try to get values of several consecutive variables, "P1..3" for example, I get reply without spaces, so it's impossible to split it to individual values.

So if P1=10, P2=200, P3=3, I get "102003".

RawGetResponseEx function gives the same result but with "-" sign at the end: "102003-".

 

How can I get many values, separated with specified (known) charachter?

Something like "10 200 3" or "10&200&3".

Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

I use GetResponseEx function in my C# app to get values from Clipper board.

 

But when I try to get values of several consecutive variables, "P1..3" for example, I get reply without spaces, so it's impossible to split it to individual values.

So if P1=10, P2=200, P3=3, I get "102003".

RawGetResponseEx function gives the same result but with "-" sign at the end: "102003-".

 

How can I get many values, separated with specified (known) charachter?

Something like "10 200 3" or "10&200&3".

Link to comment
Share on other sites

I've been exploring the problem and found that actually there are separators (new line symbols I suppose) between values in the received string.

The problem is that TextBox control does not show it, but the simple Label control does!

So the reason is in my app, not in PMAC.

[attachment=862]

Link to comment
Share on other sites

I've been exploring the problem and found that actually there are separators (new line symbols I suppose) between values in the received string.

The problem is that TextBox control does not show it, but the simple Label control does!

So the reason is in my app, not in PMAC.

2112924502_3ValuesfromPMAC.png.0ef9e36452ceaae5781b66640baa76de.png

Link to comment
Share on other sites

PMAC's handshake control variable I3 controls handshake characters that come back from PMAC along with the response.

 

For I3=2 (Pewin32Pro2 default), response to multiple queries are as follows:

With I3=2:

P1..3...... ; Valid command requiring data response

255075

#1J+........ ; Valid command not requiring data response

....... ; Acknowledging character

UUU .......... ; Invalid command

............. ; PMAC reports error

 

It is responsibility of caller to handle all control characters. TextBox does not add line with .

 

In GetResponseEx() if you pass the bAddlf flag as TRUE then it will replace with . See the code bellow from PcommServer getResponseEx() function.

 

rret = GetLineEx( dwDevice, str, 255);

cc = COMM_CHARS(rret);

if(cc > 0)

{

// Change '\r' or add linefeed if requested

if(bAddLF && str[cc - 1] == '\r')

str[cc - 1] = '\n';

ret += cc;

answer += str;

}

Link to comment
Share on other sites

PMAC's handshake control variable I3 controls handshake characters that come back from PMAC along with the response.

 

For I3=2 (Pewin32Pro2 default), response to multiple queries are as follows:

With I3=2:

P1..3...... ; Valid command requiring data response

255075

#1J+........ ; Valid command not requiring data response

....... ; Acknowledging character

UUU .......... ; Invalid command

............. ; PMAC reports error

 

It is responsibility of caller to handle all control characters. TextBox does not add line with .

 

In GetResponseEx() if you pass the bAddlf flag as TRUE then it will replace with . See the code bellow from PcommServer getResponseEx() function.

 

rret = GetLineEx( dwDevice, str, 255);

cc = COMM_CHARS(rret);

if(cc > 0)

{

// Change '\r' or add linefeed if requested

if(bAddLF && str[cc - 1] == '\r')

str[cc - 1] = '\n';

ret += cc;

answer += str;

}

Link to comment
Share on other sites

After I posted the response I noticed that this text box ate all my control characters

 

Correct sequence of response with I3=2 is (I removed <> around the control characters)

 

With I3=2:

P1..3 CR ...... ; Valid command requiring data response

25 CR 50 CR 75 CR ACK

; PMAC responds with requested data

Link to comment
Share on other sites

After I posted the response I noticed that this text box ate all my control characters

 

Correct sequence of response with I3=2 is (I removed <> around the control characters)

 

With I3=2:

P1..3 CR ...... ; Valid command requiring data response

25 CR 50 CR 75 CR ACK

; PMAC responds with requested data

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share


×
×
  • Create New...