Modbus serial

Apr 24, 2013 at 6:54 PM
Hello, I have a device that communicates to a .NET application on windows pc. The application uses Modbus to communicate with a VCP (virtual com port) on the computer which then communicates with the device over a usb cable.

I would like to port this functionality onto a windows phone, however, I'm confused by mentions of modbus and modbus/tcp. How would you best recommend I proceed, and do you think your libraries would allow me to communicate on a phone via this VCP mechanism?
Coordinator
Apr 25, 2013 at 4:20 AM
Hello.
There are two (major) versions of Modbus protocol: RTU, which relies on the serial port, and TCP, which is targeted for any IP-feasible medium. Note that you might decide to use the Modbus TCP over a serial or so, but that won't be standard, nor reliable.

As far I know, the Windows Phones don't expose anything else than a tcp or udp socket. Moreover, that IP connection is only thru the radio, so wi-fi or the broadcasting cellular network.
http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff637518(v=vs.105).aspx

So, I believe that the simplest way to make your phone communicating with the pc app is via any wi-fi home router.
Please, tell me whether I answered to your question or not.
Cheers
Apr 25, 2013 at 2:24 PM
You have not answered it entirely. There seems to be some confusion (i'm sure my fault) about the system I'm discussing. I'm not talking about my phone talking to a pc app. I'm talking about having my phone communicate via modbus to a device over the usb cable. I already have a pc application that can do this using .net and by installing VCP drivers on the pc that allows the pc application to treat a usb cable as pure serial.

Physically I can clearly connect the phone to the device using the very same cable, the question then is about the ability to push serial modbus communication over that wire to this device.
Coordinator
Apr 26, 2013 at 3:49 AM
This time it's me not being sure to have understand.
PC and device are okay. Why you state "I can clearly connect the phone ... "? Are you able to wire the phone to the device? This sounds very new to me...
Are you meaning to simply connect the USB cable from the phone to the device? If so, I don't know how to access the usb communication in the phone application.
Cheers
Apr 26, 2013 at 2:33 PM
You got it. Phone ----> device, over the usb cable that all smart phones have. Imagine you simply walk up to the device, you plug your phone into it and you can then do what you need to do, without a computer. I'm not sure how NEW this is, but the software to do all of this exists on PC and a Windows phone also supports .NET. I was hoping that within a community and a group that deals with raw serial communications on a very frequent basis, that doing serial communications from the phone wouldnt be that scary.
Coordinator
Apr 26, 2013 at 2:59 PM
I don't think it's possible:
http://social.msdn.microsoft.com/forums/en-us/wptools/thread/82d9aa7a-50f9-4471-8598-8cb9001e7962

BTW, which kind of device are you considering? The phone is also a "slave device" from the USB perspective, and you can't wire to another "slave device": it must be a usb "master".
AFAIK, the Windows Phones yield a series of ways to exchange data: the most famous is the socket, but requires at least a wi-fi access-point in order to work.
Alternatively, you may use the Bluetooth, or the RF-ID (but it's pretty limited due its peculiarity).

Please, bear in mind that a phone (as well as a tablet) is much "closed" as a normal pc: you can do a small fraction of things other than a regular platform.
Cheers
Apr 26, 2013 at 3:12 PM
Android phones post version 3.3 have the ability to work in "host mode" using an on to go cable. I was hoping the same functionality exists here. Technologies and APIs aside let's not forget that we have a small computer (the phone) and a cable that it can attach to. The phone can send signals down this wire, therefor none of this is impossible. In the end, all that has to happen is that zero's and ones have to be written to the cable, we know this happens all the time as the phone syncs with the pc over this very same cable, is not just used for power.
Apr 26, 2013 at 3:20 PM
Another option would be to use a tablet, can they run in host mode?
Coordinator
Apr 26, 2013 at 4:08 PM
Edited Apr 26, 2013 at 4:09 PM
I completely agree about the physical perspective, but...what can I do?

In the Windows world there are two kinds of "tablets":
  • tablets running regular Win7 or Win8, and that are nothing different than any desktop pc (unless they expose any usb socket);
  • tablets running WinRT (ARM-powered), and those are much more similar to a phone, because their huge "shields" around the physical layer.
The regular Windows, of course, behaves as any other Windows...so, you can use a tablet. For instance, my wife owns an Acer Iconia W700, which is a full-featured tablet, but runs Windows 8. I believe the new Surface Pro should be fine as well.
Any Windows RT device, such as the Surface RT, won't run the library, because the APIs are very different. Moreover, it does not expose any USB-communication API.

Another completely different option (which honestly I never tried) is using the Modbus library on Android, compiling it for Mono. My sources have been tested against Mono (desktop), but I still hadn't released (due the few spare time).
You may try it, though. I don't know whether a typical Android-phone/tablet will work, but...I believe should do!

Let me know, just in case.
Cheers