AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

receive bytes from srv1

The forum is to discuss topics related to robotics, like building robot, controlling it, its software and hardware, etc.

receive bytes from srv1

Postby ntouros » Wed Mar 23, 2011 5:24 pm

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 !!
ntouros
 
Posts: 24
Joined: Sat Dec 05, 2009 5:23 pm

Re: receive bytes from srv1

Postby andrew.kirillov » Wed Mar 23, 2011 8:36 pm

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".
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3446
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: receive bytes from srv1

Postby ntouros » Wed Mar 23, 2011 9:58 pm

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.
ntouros
 
Posts: 24
Joined: Sat Dec 05, 2009 5:23 pm

Re: receive bytes from srv1

Postby andrew.kirillov » Wed Mar 23, 2011 10:14 pm

If you want to get reply from SRV, then you better check responseBuffer of SendAndReceive().
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3446
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: receive bytes from srv1

Postby ntouros » Wed Mar 23, 2011 11:31 pm

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
ntouros
 
Posts: 24
Joined: Sat Dec 05, 2009 5:23 pm

Re: receive bytes from srv1

Postby andrew.kirillov » Thu Mar 24, 2011 10:58 am

Code: Select all
byte[] response = new byte[100];
int read = SendAndReceive( new byte[] { (byte) 't' }, response );
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3446
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: receive bytes from srv1

Postby ntouros » Fri Mar 25, 2011 3:19 pm

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
ntouros
 
Posts: 24
Joined: Sat Dec 05, 2009 5:23 pm




Return to Robotics