ravilolam
Posts: 15
Joined: Mon Apr 27, 2009 9:03 pm
Location: India

ServiceStream.BeginRead problem

Thu May 07, 2009 11:00 pm

Hi,

I am working on a bluetooth sample, in which I am able to discover devices and services. But not able to read the stream from the service.

The following error is occurred.

service not open

object name: ServiceStream


This error is being occured from readCallback function when i close the service.

Help me please.

Thanks & Regards
Ravikumar Lolam

Jonas
Posts: 2319
Joined: Mon Jan 09, 2006 2:20 pm
Location: Sweden

RE: ServiceStream.BeginRead problem

Fri May 08, 2009 9:18 am

What do you mean with, when you close the service? If you have closed the Stream it's no wonder that it says Service not open, yes?

Regards,
Jonas

ravilolam
Posts: 15
Joined: Mon Apr 27, 2009 9:03 pm
Location: India

RE: ServiceStream.BeginRead problem

Fri May 15, 2009 12:04 pm

Originally posted by Jonas

What do you mean with, when you close the service? If you have closed the Stream it's no wonder that it says Service not open, yes?

Regards,
Jonas


Actually I am not closing any stream. I am just running the FindAndConnect sample. It is able to discover the devices and services. But the sample is not able to read the service stream from the device.

Thanks & Regards
Ravikumar Lolam

ravilolam
Posts: 15
Joined: Mon Apr 27, 2009 9:03 pm
Location: India

RE: ServiceStream.BeginRead problem

Fri May 15, 2009 12:07 pm

Originally posted by ravilolam

Originally posted by Jonas

What do you mean with, when you close the service? If you have closed the Stream it's no wonder that it says Service not open, yes?

Regards,
Jonas


Actually I am not closing any stream. I am just running the FindAndConnect sample. It is able to discover the devices and services. But the sample is not able to read the service stream from the device.

Thanks & Regards
Ravikumar Lolam


could you please tell me why the sample is not able to read the stream from the device. Do i need to set any permissions on the device?

Please help me to resolve the issue.



Thanks & Regards
Ravikumar Lolam

ravilolam
Posts: 15
Joined: Mon Apr 27, 2009 9:03 pm
Location: India

RE: ServiceStream.BeginRead problem

Fri May 15, 2009 12:11 pm

Originally posted by ravilolam

Originally posted by ravilolam

Originally posted by Jonas

What do you mean with, when you close the service? If you have closed the Stream it's no wonder that it says Service not open, yes?

Regards,
Jonas


Actually I am not closing any stream. I am just running the FindAndConnect sample. It is able to discover the devices and services. But the sample is not able to read the service stream from the device.

Thanks & Regards
Ravikumar Lolam


could you please tell me why the sample is not able to read the stream from the device. Do i need to set any permissions on the device?

Please help me to resolve the issue.



Thanks & Regards
Ravikumar Lolam


This is the place where i am getting the error.

Code: Select all

		private void serviceList_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			// Close any connections that are open
			//

			if(currentService != null)
			{
				currentStream.Close();

				currentService	= null;
				currentStream	= null;
			}
			
			// Attempt to connect to the service
			//

			// Get service object from list box
			currentService = (RemoteService) serviceList.SelectedItem;

			try
			{
				// Connect to service by reading its Stream
				currentStream = currentService.Stream;

	            <font color="red">currentStream.BeginRead(m_buffer, 0, m_buffer.Length, new AsyncCallback(readCallback), currentStream);</font id="red">

				closeConnection.Enabled		= true;
				serviceList.Enabled			= false;
				lStatus.Text = "Receiving data...";
			} 
			catch (Exception exc)
			{
				MessageBox.Show(exc.Message);
				currentService = null;
			}
		}

In the red colored line the readCallBack method is not being executed. Why this happens? What will be the solution?


Thanks & Regards
Ravikumar Lolam

Jonas
Posts: 2319
Joined: Mon Jan 09, 2006 2:20 pm
Location: Sweden

RE: ServiceStream.BeginRead problem

Fri May 15, 2009 1:44 pm

There's nothing coming in on the Stream?
Or are you still getting the error from your first post?

Regards,
Jonas

ravilolam
Posts: 15
Joined: Mon Apr 27, 2009 9:03 pm
Location: India

RE: ServiceStream.BeginRead problem

Sun May 17, 2009 2:38 pm

Originally posted by Jonas

There's nothing coming in on the Stream?
Or are you still getting the error from your first post?

Regards,
Jonas



If i execute the above event atleast i should get some bytes from the service, but here i am getting zero bytes of data.

What will be the problem like.

Help me please.

I am trying to solve this issue since 2 months, but there is no result.


Thanks & Regards
Ravikumar Lolam

Jonas
Posts: 2319
Joined: Mon Jan 09, 2006 2:20 pm
Location: Sweden

RE: ServiceStream.BeginRead problem

Mon May 18, 2009 11:00 am

The only problem would be that your device isn't sending any data, as the callback should fire once some data appears on the Stream.

Regards,
Jonas

ravilolam
Posts: 15
Joined: Mon Apr 27, 2009 9:03 pm
Location: India

RE: ServiceStream.BeginRead problem

Tue May 19, 2009 11:17 am

Originally posted by Jonas

The only problem would be that your device isn't sending any data, as the callback should fire once some data appears on the Stream.

Regards,
Jonas



Ok. This Might be the cause. But I am able to execute the "Object Push" sample from the same device.

The Object push sample is writing the stream to the receiving device. But the FindAndConnect sample is not able to read the stream.

When ever i click on "Close" button in "FindAndConnect" sample, I am getting the following error.

<font color="red">

stream not open
Object: serviceStream

</font id="red">

What would be the reason. Why i am getting this error.

Thanks & Regards
Ravikumar Lolam

Jonas
Posts: 2319
Joined: Mon Jan 09, 2006 2:20 pm
Location: Sweden

RE: ServiceStream.BeginRead problem

Tue May 19, 2009 11:38 am

You are getting this error because the stream is closed, simple as that.
But I don't quite understand what you are trying to do here. You are executing the ObjectPush sample on the remote device and then you try to connect to it with the FindAndConnect sample? On that same service? That won't work since the other device is actively using that service to send data to you, so that service won't be available for you to connect to.

Regards,
Jonas

ravilolam
Posts: 15
Joined: Mon Apr 27, 2009 9:03 pm
Location: India

RE: ServiceStream.BeginRead problem

Wed May 20, 2009 5:58 pm

Originally posted by Jonas

You are getting this error because the stream is closed, simple as that.
But I don't quite understand what you are trying to do here. You are executing the ObjectPush sample on the remote device and then you try to connect to it with the FindAndConnect sample? On that same service? That won't work since the other device is actively using that service to send data to you, so that service won't be available for you to connect to.

Regards,
Jonas


Dear Jonas,

I found the place from which the error being occurred. I am running "FindAndConnect" sample. The following events are working fine


Device Discovery
Service Discovery

But in the following event i am getting the error.


Reading the stream from the service.


See the following event in which the problem is occurred

Code: Select all

private void serviceList_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			// Close any connections that are open
			//

			if(currentService != null)
			{
				currentStream.Close();

				currentService	= null;
				currentStream	= null;
			}
			
			// Attempt to connect to the service
			//

			// Get service object from list box
			currentService = (RemoteService) serviceList.SelectedItem;

			try
			{
				// Connect to service by reading its Stream
				currentStream = currentService.Stream;

<font color="red">	            
currentStream.BeginRead(m_buffer, 0, m_buffer.Length, new AsyncCallback(readCallback), currentStream);
</font id="red">

				closeConnection.Enabled		= true;
				serviceList.Enabled			= false;
				lStatus.Text = "Receiving data...";
			} 
			catch (Exception exc)
			{
				MessageBox.Show(exc.Message);
				currentService = null;
			}
		}
If the control reaches to the line colored red.

when the currentStream.BeginRead being called it is going into the wait state causing the application not respond.

This is the error:

<font color="red">

The CLR has been unable to transition from COM context 0x2950e8 to COM context 0x295258 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.

</font id="red">

Please give me the solution for this problem.

Thanks & Regards
Ravikumar Lolam

Jonas
Posts: 2319
Joined: Mon Jan 09, 2006 2:20 pm
Location: Sweden

RE: ServiceStream.BeginRead problem

Wed May 20, 2009 9:35 pm

I've never seen that error before.
What version of Visual Studio are you running and what .NET version?

Regards,
Jonas

ravilolam
Posts: 15
Joined: Mon Apr 27, 2009 9:03 pm
Location: India

RE: ServiceStream.BeginRead problem

Thu May 21, 2009 12:42 pm

Originally posted by Jonas

I've never seen that error before.
What version of Visual Studio are you running and what .NET version?

Regards,
Jonas


Dear Jonas,

I am using the following softwares


Visual Studio 2005
.Net Framework 2.0
Franson BlueTools SDK v1.21 build 848



Could you please tell me what are the required software to successfully run the <font color="blue">FindAndConnect</font id="blue"> Application.

Shall i give any permissions to successfully run the sample.

I am requesting you to give me a brief explanation about the <font color="blue">FindAndConnect</font id="blue"> Sample.


How does the sample works?


Thanks & Regards
Ravikumar Lolam

Jonas
Posts: 2319
Joined: Mon Jan 09, 2006 2:20 pm
Location: Sweden

RE: ServiceStream.BeginRead problem

Fri May 22, 2009 1:26 am

No, it should run very fine on .NET 2.0 and Visual Studio 2005.
I have no solution for you, I've never seen the error before.

Regards,
Jonas

ravilolam
Posts: 15
Joined: Mon Apr 27, 2009 9:03 pm
Location: India

RE: ServiceStream.BeginRead problem

Fri May 22, 2009 12:03 pm

Originally posted by Jonas

No, it should run very fine on .NET 2.0 and Visual Studio 2005.
I have no solution for you, I've never seen the error before.

Regards,
Jonas


Dear Jonas,

If you don't mind can you answer the following questions please.


Are you able to get the bytes from the selected service?
Which version of Blutools software you have used for testing?
Which Operating System You were tried on?


Could you please answer me the above questions.


Thanks & Regards
Ravikumar Lolam

Return to “BlueTools”