I need big help using Winsock
I need big help using Winsock
I need big help using Winsock
I need big help using Winsock
I need big help using Winsock
I need big help using Winsock I need big help using Winsock I need big help using Winsock I need big help using Winsock I need big help using Winsock I need big help using Winsock I need big help using Winsock I need big help using Winsock
I need big help using Winsock I need big help using Winsock
I need big help using Winsock
Go Back  Xtreme Visual Basic Talk > > > I need big help using Winsock


Reply
 
Thread Tools Display Modes
  #1  
Old 06-26-2006, 06:16 AM
viper550 viper550 is offline
Newcomer
 
Join Date: Jan 2006
Posts: 16
Default I need big help using Winsock


Ok first of all i must say that im not very experienced with visual basic in general and i have never used winsock before.

I have a project where i have to control a robot from a pc using a vb interface i created.The most important thing is that it must be done wireless.Until now i made the vb program so i could control the robot through the serial port.But now that i bought everything i needed for the wireless communication i need to change my program so i can control it through the wireless lan.

I will try to explain how i made the connections.Fot the pc i used a usb wireless lan adapter.The robot has an access point which is connected to a netgear switch.On the switch i have also connected an ip camera.Since the robot has only a serial port i bought a rs232/ethernet adapter so i could connect the robot with the switch.

The ip addresses are the following:

192.168.2.1 usb wireless adapter
192.168.2.5 robot access point
192.168.2.7 rs232/ethernet adapter connected to the robot's serial port

All i want to do is to be able to sent some ascii codes everytime i press the keyboard arrows.

I know that i have to use winsock to be able to communicate with the robot.I found some winsock tutorials to help me but i couldnt make it work.If anyone can help me i would be very thankful.
Reply With Quote
  #2  
Old 06-26-2006, 09:08 AM
Fork501's Avatar
Fork501 Fork501 is offline
Freshman
 
Join Date: Mar 2006
Location: Weston, Fl
Posts: 48
Default

Quote:
Originally Posted by viper550
Ok first of all i must say that im not very experienced with visual basic in general and i have never used winsock before.

I have a project where i have to control a robot from a pc using a vb interface i created.The most important thing is that it must be done wireless.Until now i made the vb program so i could control the robot through the serial port.But now that i bought everything i needed for the wireless communication i need to change my program so i can control it through the wireless lan.

I will try to explain how i made the connections.Fot the pc i used a usb wireless lan adapter.The robot has an access point which is connected to a netgear switch.On the switch i have also connected an ip camera.Since the robot has only a serial port i bought a rs232/ethernet adapter so i could connect the robot with the switch.

The ip addresses are the following:

192.168.2.1 usb wireless adapter
192.168.2.5 robot access point
192.168.2.7 rs232/ethernet adapter connected to the robot's serial port

All i want to do is to be able to sent some ascii codes everytime i press the keyboard arrows.

I know that i have to use winsock to be able to communicate with the robot.I found some winsock tutorials to help me but i couldnt make it work.If anyone can help me i would be very thankful.


Before you can send any commands, your robot has to be able to answer the call. I'm not sure what software you're using on the robot, but it would have to be able to accept a connection.

Example:

In Visual Basic, you say:

Code:
Private Sub Command1_Click() winsock1.connect End Sub

That starts the connection (considering you have the default settings on the Winsock1 object itself).

Then from a remote end, you would have another VB program (as an example) with a command such as:

Code:
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long) Winsock1.Accept (requestID) End Sub

This would start out your program so that you can then freely send commands.

As for your robot, I don't know how it would accept commands like that because I don't know what software you are using.

You could try a Microsoft COMM Control with it, but you would need an infra-red transmitter to get it to work like that.

~Derek
Reply With Quote
  #3  
Old 06-26-2006, 09:18 AM
viper550 viper550 is offline
Newcomer
 
Join Date: Jan 2006
Posts: 16
Default

The robot is simply using its serial port to send/receive data.It only has a basic stamp microcontroller that i have programmed with the basic stamp editor.

I dont know if my thinking is correct but i think the pc will send the data to the rs232/ethernet adapter and then the adapter will send the data to the robot.Can't i send data from the pc to a specified ip address that is the adapter?
Reply With Quote
  #4  
Old 06-26-2006, 09:35 AM
Fork501's Avatar
Fork501 Fork501 is offline
Freshman
 
Join Date: Mar 2006
Location: Weston, Fl
Posts: 48
Default

Quote:
Originally Posted by viper550
The robot is simply using its serial port to send/receive data.It only has a basic stamp microcontroller that i have programmed with the basic stamp editor.

I dont know if my thinking is correct but i think the pc will send the data to the rs232/ethernet adapter and then the adapter will send the data to the robot.Can't i send data from the pc to a specified ip address that is the adapter?

hmmm... It might work (keyword might)

Try this:

First, ping the IP address of the robot's ethernet controller (I know it sounds dumb or w/e, but I like to ping before I try to transmit)

Next, open a line of code in your application like this:

Code:
Private Sub Winsock1_Connect() MsgBox "Connected" End Sub Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) Dim inData As String Winsock1.GetData inData MsgBox inData End Sub

I like to use message boxes instead of debug.print, because they're more obvious.

Now try connecting to your robot with the IP address of the ethernet controller. See if anything comes back. If you don't at least get the "Connected" message box, then it won't work for you.

~Derek
Reply With Quote
  #5  
Old 06-26-2006, 10:14 AM
dilettante's Avatar
dilettanteI need big help using Winsock dilettante is offline
Underclocked lifestyle

Forum Leader
* Guru *
 
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,520
Default

I assume your robot is dragging around an access point in order to create a totem pole like:

|control pc|
| wifi nic |

~ radio ~
~ link ~

|wifi accpt|

- ethernet -
- cable -

|eth/serial|

- serial -
- cable -

| robot |


Hmm. I guess you need something to act as a WiFi/Ethernet adapter, to plug into your Ethernet/Serial adapter. Of course a Basic Stamp isn't going to support any direct WiFi connections. Ideally I'd toss the Stamp and move to another platform, which in the long run would be cheaper, lighter, more rugged. But if wishes were fishes...


Ok, the first thing you need to do is get out the documentation on this Ethernet/Serial adapter. I assume you can assign it a fixed IP address from a range the access point will serve, etc.

The important thing is to determine what kinds of emulations it supports. It may do raw TCP, it may do Telnet, it may do UDP... or possibly it has several of these as options or even something else proprietary. Most likely it has a way to handle at least some of the "out of band" RS-232 signals (RTS/CTS, etc.).

But that's the real question: what does this device "look like" to a program at the other end of the network? The docs should at least tell you that much.
Reply With Quote
  #6  
Old 06-27-2006, 08:12 AM
viper550 viper550 is offline
Newcomer
 
Join Date: Jan 2006
Posts: 16
Default

Ok i found what i had to do.All i did is to add the winsock1.connect command to the form and the winsock1.senddata to a command button.Now my robot works great.The problem before was that i had the 2 commands together and for some reason it couldn't work.Now everything is ok.

dilletante you dont have to use anything between the access point and the rs232/ethernet adapter.You can connect the 2 with an ethernet cable.Although i use between them a netgear switch cause i want to connect an ip camera also.

Thank you guys for all your help.Finally i can finish my project.Keep up the good work.
Reply With Quote
  #7  
Old 06-27-2006, 11:19 AM
Fork501's Avatar
Fork501 Fork501 is offline
Freshman
 
Join Date: Mar 2006
Location: Weston, Fl
Posts: 48
Default

Quote:
Originally Posted by viper550
Ok i found what i had to do.All i did is to add the winsock1.connect command to the form and the winsock1.senddata to a command button.Now my robot works great.The problem before was that i had the 2 commands together and for some reason it couldn't work.Now everything is ok.

dilletante you dont have to use anything between the access point and the rs232/ethernet adapter.You can connect the 2 with an ethernet cable.Although i use between them a netgear switch cause i want to connect an ip camera also.

Thank you guys for all your help.Finally i can finish my project.Keep up the good work.

All that matters is that it works So YOU keep up the good work lol

~Derek
Reply With Quote
  #8  
Old 06-27-2006, 01:45 PM
darkforcesjedi's Avatar
darkforcesjediI need big help using Winsock darkforcesjedi is offline
Trust me, I'm an

* Expert *
 
Join Date: Apr 2001
Location: In ur base, pwnin d00dz
Posts: 1,964
Default

The winsock has a property to tell you if it is connected. I believe the property is called "State". Look in the documentation. Both can be used in the same button as long as you wat for the connection to complete:

Code:
winsock.connect While winsock.State = sckConnecting 'that might be it, but I don't remember... haven't used a winsock in forever DoEvents Wend If winsock.State = sckConnected 'successfully connected winsock.senddata MyStuff Else 'something went wrong End If
__________________
To err is human; to debug, divine.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
I need big help using Winsock
I need big help using Winsock
I need big help using Winsock I need big help using Winsock
I need big help using Winsock
I need big help using Winsock
I need big help using Winsock I need big help using Winsock I need big help using Winsock I need big help using Winsock I need big help using Winsock I need big help using Winsock I need big help using Winsock
I need big help using Winsock
I need big help using Winsock
 
I need big help using Winsock
I need big help using Winsock
 
-->