Hi All,
Currently I am working with Handheld devices. I am targeting Symbol devices [MC-50, PPT8800, MC-1000, MC-70]. I am developing custom order-entry system, which will run on these devices.
I am using C# [VS2003] to build the smart device application. One of the prime requirement of my client is to provide data transfer through Serial & USB connectivity. Here is where I am stucked!!
I have developed the serial data transfer part, and it is working fine. But I have no idea how to go ahead with the USB part.
Few devices like MC50 & MC70 doesnot have serial connectivity. So the only choice is using USB port to read data from device.
How the transfer will be done :
Our smart device application will run on handheld device, from where we will transfer information to applications, running on desktop, through USB Port. So I need guidance to write to port and to read the same through desktop application.
While writing to USB port, application will run on DotNet CF, and while reading from USB port, receiving application will run on DotNet Framework.
Can anyone guide me through, how to go ahead with this?
Will be obliged if I receive quick feedback, as the requirement is urgent ![]()
Thanks in advance.
Regards,
Sanjib Choudhury.
-
-
Hi TadeJk..
I m doing web based call accounting system in asp.net(c#)
for dat I hv 2 connect PBX(Private Branch Exchange) With PC.
Collect CDR(Call Detail Records) form PBX.& Brodcast Live!
I m new in networking & even in asp.net.
PBX has 3 interfaces.
1) Com
2) Network Port (Lisnr & Client )
3) File
I want to know for Network Port How can I connect PBX with PC & colllect CDR.
can I use Tcpclient & Tcplistner classes...??
Plz send some code snipt..
Reply soon...It's Urgent!![A]
Thanx. -
For the desktop part, you could use the http://www.icsharpcode.net/OpenSource/SharpUSBLib/default.aspx library .. it works in windows/linux.
For the device part .. I don't know. Perhaps if you found a library and wrote a wrapper around it - like SharpUSBLib is a wrapper around libusb library.
Write back what you figured out
Regards,
Tadej -
You could also look at the Open Net Smart Device Framework. It has loads of different things that are aimed specifically at the Compact Framework. It's well worth a look.
-
Thanks Tadejk & An_Angel for the quick post.
Let me go one by one:
Tadejk your link seems helpful. I am still struggling to get hold of something which works on CompactFramework. I havent got the time to dig into details [SharpUSBLib], will soon be posting regarding that
My first target is to transmit data from my device application. You already provided me with something to read the data. Thanks for that. My second part will be over before I figure-out my first hurdle, I guess
An_Angel thanks for the link. Actually I have already visited the site you mentioned, but failed to find anything on USB. I did my serial communication part using openNetCF.IO.Serial assembly using VS2003.
In VS2005 MS has included an assembly for Serial communication, but USB is still away from reach
I am trying to contact Symbol guys [manufacturer company] side-by-side, but still miles away from any kinda help !!
Thanks again for the help, please do post, if you anyone of you, come across wih something, which might help me out of this issue.
Rest others, dont just view the post, please drop your ideas or suggestions, and help me out.
Thanks & Regards,
Sanjib Choudhury. -
I'm wondering something .. you said the device is connected via usb to the PC.
Does it also connect to activesync everytime you connect it to the usb or not?
Hope you understand what I'm trying to ask
If not, please feel free to demand a further elaboration 
Regards,
Tadej -
Hi Tadejk,
Yes I guess I have understood your point. When I deploy my application I always connect to device through ActiveSync. But this will not be the case when I'll transfer data from my device application to my desktop application.
I need to transfer my data independently without the help of any synchronisation application in between. So my device application should know how and where to locate specific USB port, check for the device on that port and write to the port.
Now my desktop application will know there is data on the port, and it will read that.
This is exactly what I have done in case of serial connectivity, have to do the same for USB too
Thanks for your time, looking forward to hear from you
Regards,
Sanjib Choudhury. -
If you could install ActiveSync on every device you're going to connect to, then your problems are solved .. you can easily connect via simple TCP connection .. and it also works via WiFi (you just have to change the hostname .. depends on your config), so it's a win-win situation

The only question, of course, is whether or not you can have ActiveSync everywhere.
I've done this a couple of times, and it's simply the simplest solution
Think about it
Regards,
Tadej -
Hi TadejK,
Thanks for your reply. Your idea compelled me to think.
I just checked my device, and I found ActiveSync sub-directory under windows directory. Files which I found on my device, under ActiveSync folder, are: GCounterFile, SchedSync. Are these the only files, which I need on my device to handle my TCP communication with my desktop software, or do I need some other files !!
I guess in PocketPC ActiveSync client is installed by default, coz I didnt installed those two files on my device. Wait-a-min...did you mean ActiveSync server should be there on my device? I mean ActiveSync which gets installed on desktop is full server version, right? The one found on device to Sync with Desktop is client version of ActiveSync. Correct me if I am wrong
Bottom line, if the client version of ActiveSync is all I need on my device to run my application and transmit data to my desktop through TCP, then I dont need to install ActiveSync on all devices.
So in that case, all I need is ActiveSync desktop version to be shiped with my setup application. And I will require ActiveSync to be up & running, whenever my desktop application launches.
Well, thanks a ton for this fabulous idea, please clarify what ActiveSync stuffs needs to be installed on device. Depending on this, I can come into conclusion, how to implement the whole idea of yours
Thanks & Regards,
Sanjib Choudhury. -
Every PocketPC device has the ability (the software installed) to connect to ActiveSync. Therefor, all you need, is ActiveSync installed on your desktop pc.
Upon installation (and hardware connection), your device should automatically connect to the PC.
After this is done, you should have access to the internet on your PocketPC device (if the desktop pc has internet, of course;)).
To sum up - install ActiveSync on your desktop PC, connect your device, click a few things on the desktop PC (stupid ActiveSync
), and you're ready to go. All you need is the hostname to your desktop PC (it's always PPP_PEER !).
Now, you just need a tcp server on the PC, listening to a port (like 666), and a tcp client on the pocket pc, which will simply connect to PPP_PEER on your port (like 666).
If what I wrote didn't make much sense .. please, don't hesitate to ask
I'm not a native english speaker 
Regards,
Tadej -
Hi TadejK,
TadejK wrote:you should have access to the internet on your PocketPC device (if the desktop pc has internet, of course
).
I believe this will be the biggest hurdle, as I got a hint that, it might not be the situation for all of our users
Mananagement wants application should talk independently in an internet-less environment too. [C]
I have created two sample applications, one which writes on port another which listens to port, as per your idea. Will post the same outta here, once I finish testing that thoroughly.
Meanwhile I need to seriously re-think management's decision
Thanks for your time and suggestions/ideas. Looking forward for some great suggestions, once again...By the way- you are good in English, trust me:P
Thanks & Regards,
Sanjib Choudhury.
-
The access to the internet is just a way of testing if the activesync connection is really working (and that you have the settings set correctly).
Otherwise - of course it works in an internet-less environment.
In fact - your PC doesn't even have to be connected to a network
Regards,
Tadej
ps: if you need any help with your code, just ask - I've done exactly this a couple of times already
-
TadejK wrote:The access to the internet is just a way of testing if the activesync connection is really working (and that you have the settings set correctly).
Otherwise - of course it works in an internet-less environment.
In fact - your PC doesn't even have to be connected to a network
Hi TadejK,
Thanks a ton for the informations. I appreciate your continuous help and suggestions.
Let me give you a rough sketch, what I was coding, to implement your idea.
Client Application[On device]
static void ConnectAndWrite()
{
try
{
TcpClient tcpclnt = new TcpClient();
MessageBox.Show("Connecting.....");
tcpclnt.Connect("PPP_PEER",5656);
MessageBox.Show("Connected");
String str="Sent from client application.";
NetworkStream stm = tcpclnt.GetStream();
ASCIIEncoding asen= new ASCIIEncoding();
byte[] ba=asen.GetBytes(str);
MessageBox.Show("Transmitting.....");
//Write on server port
stm.Write(ba,0,ba.Length);
tcpclnt.Close();
}
catch (Exception e)
{
MessageBox.Show("Error..... " + e.InnerException);
}
}
Server Application[On Desktop]
static void Connect()
{
try
{
IPAddress ipAd = Dns.Resolve("PPP_PEER").AddressList[0] ;
/* Initializes the Listener */
TcpListener myList=new TcpListener(ipAd,5656);
/* Start Listeneting at the specified port */
myList.Start();
MessageBox.Show("The server is running at port 5656...");
MessageBox.Show("Waiting for a connection.....");
Socket s=myList.AcceptSocket();
MessageBox.Show("Connection accepted from " + s.RemoteEndPoint);
byte[] b=new byte[100];
int k=s.Receive(b);
MessageBox.Show("Recieved...");
for (int j=0;j<k;j++)
MessageBox.Show(Convert.ToChar(b[j]).ToString() );
/* clean up */
s.Close();
myList.Stop();
}
catch (Exception e)
{
MessageBox.Show("Error..... " + e.StackTrace);
}
}
Well where I am stucked is in the Server Application. One of the overload of TcpListener function, takes parameter of, object of IPAddress class. So whenever I am mentioning PPP_PEER, it failes to resolute. I tried giving the IP of my server, in that case it fails to read any data from my device application[both applications runs safely, but of no use!!]. So I tried resolving the PPP_PEER using Dns.Resolve() but it fails too.
Now suppose in my client application, in place of PPP_PEER I gave my server ip, and in server application too I mentioned my server ip. In this case I get an error in my client application, while connecting, which says "An existing connection was forcibly closed by the remote host ".
"Do you think, in place of this line:[In desktop application]
TcpListener myList=new TcpListener(ipAd,5656);
I should write:
TcpListener myList = new TcpListener(IPAddress.Any, 5656);
And I should keep the client application[on device], as it is now..."
I havent tried this mode yet though...
Please drop-in your suggestions, I am stucked again
Oh yeah I would love to receive your code snippets.
Thanks a ton, once again.
Regards,
Sanjib Choudhury.
-
TcpListener myList = new TcpListener(IPAddress.Any, 5656);
This looks to be better
I wanted to paste a code snippet, but realized my code was too complex (not in a good way
) for this, so I'll simply write a basic example and upload it somewhere 
I'll get back to you
Regards,
Tadej
-
Hey TadejK,
Thanks man
I'll try this:
TcpListener myList = new TcpListener(IPAddress.Any, 5656);
And also, will be waiting for ur expert code snippet
Hope to get ur reply soon!
Regards,
Sanjib Choudhury. -
Glad to be of some help/use

I've posted the code to Sandbox .. link is below
http://channel9.msdn.com/ShowPost.aspx?PostID=231690
The code isn't commented .. at all
So .. please - ask if anything isn't clear
A bit of explanation about why I use character 3 for end of transfer .. the problem is, that you can't know when the transfer is finished .. .Read should return 0, but it actually blocks, so that's not very helpful
.DataAvailable hasn't really worked for me.
Therefor, this seems to be the only way (except doing the transfer async, perhaps).
Well, anyway .. the code should work, but if you'll be able to improve it in any way, please tell me about it - we learn new things every day
Regards,
Tadej -
Hi TadejK,
So sorry for replying late. I was not doing well for couple of days, so couldnot reply to your post. Thanks a ton for sending me the link of your code snippets. Yeah though it was not commented but your coding style is clear to me
Well I tried to my code snippet and found the stuff working. I have also tried your code snippet
Well now the bad news is, Management changed their mind and seeking a communication model which works without ActiceSync.[C] Reason behind is, there is some cost included in re-distributing ActiveSync. So I need to find out a solution which works without ActiveSync in between:s
Anyways I learnt something new, that's my achievement;)
Thanks for your continuous support, ideas...Now I have to find out how it will work without ActiveSync in between:(
Dont forget to drop-in your ideas and comments, if you come across.
Thanks & Regards,
Sanjib Choudhury. -
Hope you're feeling better now

You said there's some cost in re-distributing ActiveSync .. do you mean as in the additional work that has to be done to install it, or is there a license fee, which I'm not aware of?
Well, anyway, I think you should just make a stand here - tell them that they need to choose - that they can take the ActiveSync solution, and it'll work great, fast, and you'll be able to write it in half an hour.
Or, you can spend a LOT of time developing some custom solution, which will, in the end, cost a lot more than the ActiveSync solution.
That's just my opinion.
But, otherwise, to discuss some possible solutions without ActiveSync -
perhaps you could find a driver that would map usb to a com port .. or maybe if you took a look at the PocketPC APIs - there may be something useful in there
.
Other than that .. I think I'm just about running out of fresh ideas
Hoping to hear back from you about your solution.
Regards,
Tadej
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.