Page 1 of 1

receive bytes from srv1

PostPosted: Wed Mar 23, 2011 5:24 pm
by ntouros
hi,

i am using your librarys controling srv1. Your function sendandreceive

http://www.aforgenet.com/framework/docs/html/ce8afbfb-718d-ec69-e261-bcbb2ca41c04.htm

returns the total number of bytes but i want read the received bytes how can i do this ?

thanks

ps. best regards for your work !!

Re: receive bytes from srv1

PostPosted: Wed Mar 23, 2011 8:36 pm
by andrew.kirillov
ntouros wrote:returns the total number of bytes but i want read the received bytes how can i do this ?

1) You better use some punctuation, like "," or ".", to separate your thoughts;
2) As you can see from documentation to SRV1.SendAndReceive(), the return value gives you "total bytes read into the response buffer".

Re: receive bytes from srv1

PostPosted: Wed Mar 23, 2011 9:58 pm
by ntouros
sorry for my english

probably not understood what i want because of me

for example i give

textBox1.Text = srv.SendAndReceive(StrToByteArray("R"),StrToByteArray("##Range(cm)")).ToString();

and then textbox.text = 11. This repeat for ever, obviously count the number of byte not the byte am i right ? i want to return me the range

the srv.sendandreceive() returns int not what srv says

putting this (##Range(cm) in response buffer is right ? you don't have any example

Strtobytearray() is mine fuction which converts string to byte, works perfectly. The byte send perfectly i don't have problem in this.

My problem is to receive what srv says

thanks for your applys. I appreciate your time.

Re: receive bytes from srv1

PostPosted: Wed Mar 23, 2011 10:14 pm
by andrew.kirillov
If you want to get reply from SRV, then you better check responseBuffer of SendAndReceive().

Re: receive bytes from srv1

PostPosted: Wed Mar 23, 2011 11:31 pm
by ntouros
really i have no idea how check the response buffer. There is nowhere response buffer on your code except in this fuction where i being asked for this and i dont konw what must give.

if anyone else take reply from srv1 using aforge please sent the answer

thanks

Re: receive bytes from srv1

PostPosted: Thu Mar 24, 2011 10:58 am
by andrew.kirillov
Code: Select all
byte[] response = new byte[100];
int read = SendAndReceive( new byte[] { (byte) 't' }, response );

Re: receive bytes from srv1

PostPosted: Fri Mar 25, 2011 3:19 pm
by ntouros
thank you very much. It's very usefull

I refer to other forum users if you want convert byte array to stirng use following code : System.Text.Encoding enc = System.Text.Encoding.ASCII;
string myString = enc.GetString(my byte array);

thank you again

Best regards for your work