.net - How to read weight from scale using ethernet connection -
hi first post please bare me.
i have mettler toledo xs32000l scale , trying read weight via ethernet connection , vb.net (2010) application. have found plenty of information/code serial(com) connection nothing ethernet connection.
communication mode: client & server remote host address: 192.168.0.2. remote host port number: 8001 local server port number: 8000 (scale ip: 192.168.0.1)
i able ping scale reply. have tried using hyperterminal no luck. appreciated, , post can many others come. thanks!
other resources
code vb application serial connection: http://control.com/thread/1240210560
another helpful link(but not me): http://vb.net-informations.com/communications/vb.net_socket_programming.htm
alright - despite criticism, going post solution after hours of researching. created tcp client , modified settings (ip, port, etc.) helps future programmers!
imports system.net.sockets public class form1 private sub form1_load(byval sender system.object, byval e system.eventargs) handles mybase.load call connect("192.168.0.1", "s" & vbcrlf) end sub shared sub connect(byval server [string], byval message [string]) try ' create tcpclient. ' note, client work need have tcpserver ' connected same address specified server, port ' combination. dim port int32 = 8000 dim client new tcpclient(server, port) ' translate passed message ascii , store byte array. dim data [byte]() = system.text.encoding.ascii.getbytes(message) ' client stream reading , writing. ' stream stream = client.getstream(); dim stream networkstream = client.getstream() ' send message connected tcpserver. stream.write(data, 0, data.length) 'console.writeline("sent: {0}", message) msgbox("sent: {0} " & message) ' receive tcpserver.response. ' buffer store response bytes. data = new [byte](256) {} ' string store response ascii representation. dim responsedata [string] = [string].empty ' read first batch of tcpserver response bytes. dim bytes int32 = stream.read(data, 0, data.length) responsedata = system.text.encoding.ascii.getstring(data, 0, bytes) 'console.writeline("received: {0}", responsedata) msgbox("received: {0} " & responsedata) ' close everything. stream.close() client.close() catch e argumentnullexception 'console.writeline("argumentnullexception: {0}", e) msgbox("argumentnullexception: {0}" & e.message) catch e socketexception 'console.writeline("socketexception: {0}", e) msgbox("socketexception: {0}" & e.message) end try msgbox("got point in code") 'console.writeline(controlchars.cr + " press enter continue...") 'console.read() end sub 'connect end class
Comments
Post a Comment