Enrico Rosso wrote:
>
> I'm trying to write an app to control a tcp/ip connected device.
>
> 1. On the protocol specs they say I have to send the codes as decimals.
> How do I do this with a socket class? is there a way to encode decimals
> on a string and send them as string? (i've tried using the chr command,
> but it doesn't seem to work).
Just use Socket.Write(str(myCode))
>
> 2. If the device sends something to me in decimal, will I be able to
> receive it? I mean. will the socket fire the method?
Yes. DataAvailable(). And if the device sends the code 245 to you, you
can get it with this:
dim receivedCode as integer
dim data as string
data = me.readAll
receivedCode = Val(data)
But that's just the beginning. The device will likely send more than
just one code to you, so you need to know how the codes are delimited
and write some code to extract the codes.
The same goes for the sending side; if you want to send the codes 12 and
345, you can't just send them one after another; if the device receives
"12345", how can it know it you meant 12 and 345, and not 123 and 45?
So you need to dig a little deeper into the device's docs.
Cheers,
Frank+++
--
Günter Schmidt & Co. oHG
Frank Bitterlich eMail: bitterlich at gsco dot de
Schlosserstr. 2-4 WWW: http://www.gsco.de/gsco
D-60322 Frankfurt Tel.: 069 / 156809-29
GERMANY Fax: 069 / 156809-28
|