Author Topic: wclShowError is required for operation???  (Read 3680 times)

Offline spavetti

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
wclShowError is required for operation???
« on: October 18, 2013, 10:51:44 PM »
I'm experiencing some rather curious behavior.  I started with the BluetoothClientDemo form and modified it to be a simple class that is called from a console program.

Code: [Select]
wclErrors.wclShowError(wclClient.Write(Buf, (uint)str.Length)); // WORKS

Code: [Select]
var result = wclClient.Write(Buf, (uint) str.Length);
 wclErrors.wclShowError(result); // ALSO WORKS

Code: [Select]
var result = wclClient.Write(Buf, (uint) str.Length);
 wclErrors.wclShowError(0); // DOES NOT WORK  - I'M JUST SENDING IN 0

Code: [Select]
Console.WriteLine(wclClient.Write(Buf, (uint) str.Length)); // DOES NOT WORK - NO SEND

Code: [Select]
wclClient.Write(Buf, (uint) str.Length); // DOES NOT WORK - NO SEND

Can anyone offer a reasonable explanation as to why exactly I need to use wclShowError in this way?  I need to place these functions into an architecture, and having some hidden code that could potentially open dialog boxes simply won't work.  What can I do to correct the behavior, or what have I missed???

--Scott

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3053
  • Karma: 1000
    • Soft Service Company
Re: wclShowError is required for operation???
« Reply #1 on: October 18, 2013, 11:11:56 PM »
Hello,

wclClient.Write and wclShowError are absolutely independed functions.

Most of WCL methods return error code as an operation result. wclShowError just takes this result (error code) and if it is not WCL_E_SUCCESS (0) shows a error message (and returns true). If error code is WCL_E_SUCCESS then wclShowError does not show any message (and returns false).

So in your code without wclShowError you have to analize Write operation result somehow by other way. Unfortunately without result of operation (error code) I can not say what can be wrong there.

Offline spavetti

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
Re: wclShowError is required for operation???
« Reply #2 on: October 20, 2013, 06:45:09 PM »
Error 40 - no connection

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3053
  • Karma: 1000
    • Soft Service Company
Re: wclShowError is required for operation???
« Reply #3 on: October 20, 2013, 06:50:22 PM »
So wclClient is not connected. You are trying to execute Write operation on closed wclClient. Connect to your device/server first.

Offline spavetti

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
Re: wclShowError is required for operation???
« Reply #4 on: October 20, 2013, 08:05:55 PM »
No! That's not what's happening!  The ONLY changes in my app are the ones listed in my OP.  Again. If I don't use the wclShowError, then the application fails to send.  My client device also indicates a successful connection.

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3053
  • Karma: 1000
    • Soft Service Company
Re: wclShowError is required for operation???
« Reply #5 on: October 20, 2013, 08:12:25 PM »
Unfortunately it is impossible. The only case when WCL_E_NOT_CONNECTED returned is when wclClient it not connected. So I am sure that Client is not connected (you can check it by simple checking its State property, it must be csConnected). When do you call Write method?

Offline spavetti

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
Re: wclShowError is required for operation???
« Reply #6 on: October 20, 2013, 08:45:17 PM »
I can say with certainty that this is what's I'm experiencing.  I'm sure there's a perfectly reasonable explanation for what's going on.  Is it possible that there's a library conflict?  I'm using .NET 4.0 libs, and my application is also targeted for .NET 4.0.  The sample seems to operate as expected, although I haven't tried to alter it by removing the wclShowError. 

I've been struggling to explain the behavior for days.  I'll note that the event for connection is never getting triggered for any of the original code I posted.  I never seem to get out of the Connecting state, even though it gets called back on the client demo - and I'm using that same code (with minor alterations - nothing stupid like not performing connection, give me some credit) in a relatively unaltered state.  The client device is an android tablet that does a simple echo function.   Eventually the events for data available are triggered as well.   I'm wondering why it would work at all for ANY of the code I posted if I couldn't get out of the connecting state?  And why does the magic of wclShowError create some weird success when there shouldn't be then?

Here are the steps I took:
1) Take the ClientDemo form
2) Turn the form class into an ordinary class - removing the derivation from Form
3) Remove all extraneous events for discovery
4) Change other trivial details such as changing the constructor to inject parameters - none are wcl classes, they're all primitives
5) Instantiate and try to use....

I'll attach code tomorrow when I get into work.

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3053
  • Karma: 1000
    • Soft Service Company
Re: wclShowError is required for operation???
« Reply #7 on: October 21, 2013, 06:24:29 AM »
Unfortunately I can not say what is going wrong without known what you have changed in the code. But wclShowError is not a problem.

Offline spavetti

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
Re: wclShowError is required for operation???
« Reply #8 on: October 21, 2013, 07:04:58 PM »
I did some more tests, and what I found was that I could get my code to operate in a winforms app, and not a console app.  I provided a solution with 2 projects that use identical code that was derived from the clientdemo.  Can you provide some insights on why there is a difference, or what my issue is?

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3053
  • Karma: 1000
    • Soft Service Company
Re: wclShowError is required for operation???
« Reply #9 on: October 21, 2013, 07:07:18 PM »
Hello,

WCL requires a message loop to work as some stacks and low-level drivers send its events by using Windows Messages (as it was already explained on this forum lot of times). Take a look on service demo to find out how to use WCL in non WinForm application (in application which does not have a default message loop).

Offline spavetti

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
Re: wclShowError is required for operation???
« Reply #10 on: October 21, 2013, 07:27:21 PM »
Maybe an important design constraint like should make it into the documentation, rather than on a forum?  Thanks for the assistance.

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3053
  • Karma: 1000
    • Soft Service Company
Re: wclShowError is required for operation???
« Reply #11 on: October 21, 2013, 07:29:26 PM »
You are right, we are working on updated documetation and explaing such things there. However, its a little bit hard to describe all possible issues, that is why we have forum.

Offline spavetti

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
Re: wclShowError is required for operation???
« Reply #12 on: October 21, 2013, 07:34:50 PM »
Your responses on the forum have been fantastic, Mike.  Cheers!

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3053
  • Karma: 1000
    • Soft Service Company
Re: wclShowError is required for operation???
« Reply #13 on: October 21, 2013, 07:54:46 PM »
You are very welcome

 

Sitemap 1 2 3 4 5 6 7 8 9