DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Wed, 08 Aug 2007 04:08:55 -0000,    posted on: microsoft.public.dotnet.framework.compactframework        back       

Thread Index
  1    zhangke007
          2    Daniel Strigl


Binding stream data through Tcpclient   
Hello, everyone,

Currently, I have an simple serial communication application using the
serialnet.dll tool from Franson company. What this application does is
to read the data through the com port in my windows ce 5 based
wearable computer. The data is sent from a PIC microcontroller through
the RS232 protocol.  The scenario is like whenever you press a button,
my PIC will detect the trigger and then send a single data through
RS232 port to the wearable computer.

Using the serialnet.dll file, I can read the data and show the data in
a textbox.

The code is like when you set the

   objPort.Enabled = True

whenever there is data coming from the com port, the objPort.OnRead
event will trigger the following code

   Private Sub objPort_OnRead(ByVal Data As String) Handles
objPort.OnRead

          If Data Is Nothing Then
              txtRead.Text = "Timeout"
          Else
              txtRead.Text = Data
          End If

    End Sub

And I have another simply application which adopt the TcpClient in net
cf. This part of the application can send data from the wearable
computer to the desktop PC.  The main code is like the following,

        Dim serverIP As IPAddress
        serverIP = IPAddress.Parse(ServerTextBox.Text)

        ' Try to connect to the server on port 10000
        Dim client As New TcpClient
        client.Connect(New IPEndPoint(serverIP, 10000))

        Dim startCode As [Byte]() = Encoding.ASCII.GetBytes("CONNECT|
computer" & vbCrLf)

        strm = client.GetStream()
        strm.Write(startCode, 0, startCode.Length)

So my question is how can I send the data(from the com port) through
the TcpClient to the PC. The data within the objPort_OnRead() method
is not visible to other method. I don't know how to bind this data to
the TcpClient.GetStream.write() method.

I am still new to  Visual Basic .net and .net cf. Could somebody give
me some instructions on how to solve this?

Best wishes,
Date:Wed, 08 Aug 2007 04:08:55 -0000   Author:  

Re: Binding stream data through Tcpclient   
zhangke007 schrieb:


> So my question is how can I send the data(from the com port) through
> the TcpClient to the PC. The data within the objPort_OnRead() method
> is not visible to other method. I don't know how to bind this data to
> the TcpClient.GetStream.write() method.


Are the part to read from your serial port and the part for your tcp
connection to your desktop pc in different applications? Or do you
put both in one application?

If you put both in one application I would create a worker-thread with
a queue for the tcp connection. When data are received from the serial
port I would put it to the queue, this will trigger the worker-thread
for the tcp connection. The worker-thread take the data from the queue
and send it over the tcp connection to the desktop pc.

For a sample take a look at
http://www.codeproject.com/csharp/ProcessQueue.asp

Hope this will help you!

-- 
Daniel Strigl [daniel.strigl@gmx.takethisout.at, remove 'takethisout.']
Web: http://www.hh-system.com/danielstrigl
Blog: http://geekswithblogs.net/dastblog
Date:Wed, 08 Aug 2007 09:43:25 +0200   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us