Hyper Terminal Wannabe

I need to send a command in a similar method of that of hyperterminal, using an Ethernet connection.

When I send a Command, such as #Sq1 which is a sensor query, I also get a response. I need to be able to read this also for further use in my  VB program.

Please note that is needs to be via ethernet, not Comm port.

Also note that this input and reading of data needs to be done in source code, not input by the user during run time.

I am no expert so please explain what you are saying well.

Thanks,
   Crono15M

Crono15MAsked:
Who is Participating?
 
mcriderConnect With a Mentor Commented:
You can't use the SendData method until the socket state is "connected".

You can either put your SendData command in the Winsock1_Connect subroutine, or set up a do loop waiting for the socket to be connected, like this:

do
   select case winnsock1.state
      case sckConnected
           exit do
      case sckClosed
           'SOCKET CLOSED,CLEANUP AND GET OUT
           exit do
   end select
   doevents      
loop


Cheers!

0
 
Crono15MAuthor Commented:
Edited text of question.
0
 
mcriderCommented:
You're going to have to open a connection using winsock.  This involves adding the winsock control to your program.

You can do this by right-clicking the toolbar and selecting "Components...". Then select winsock from the list.

You will need to know the IP address and port number to connect to.


There is an example of using the winsock control in the help file...

Cheers!
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Crono15MAuthor Commented:
Thanks, I do know the IP and the DataPort, and I have used WinSock to grab data before, but I have never actually sent a command over a connection.
If anyone has some source code to do it, that would be greatly appreciated.

Just say the command I want to send is #Pq 2

Thanks,
   Crono15M
0
 
mcriderCommented:
After you are connected, you want to do:

   winsock1.SendData "#Pq 2"+VbCrLf

Cheers!
0
 
Crono15MAuthor Commented:
For some reason this still does not work. The error has something to do with an improper connection status.

I know my connection is established because I am getting data from the source.

Do you need to put the code in a certain subroutine?

0
All Courses

From novice to tech pro — start learning today.