I am starting to program in C# and build applications over the web.
I have a board with a PIC microcontroller that I made that communicates with the PC via USB-Serial converter (FT232).
Now I want to do this: I want to create a website on another computer that allows you to communicate with the PC with the PIC board. Via the other computer I want to be able to control the PIC board.
I think that in order to do that I have to start learning about ActiveX, if I'm not mistaken. Does ActiveX allow me to write on another computer's serial port?
I really want to learn that.
Could you please guide me in the correct direction, and if possible a book or tutorial?
Thank you very much, and sorry for any english mistakes.
No, ActiveX is to let a web page interact with the computer of the visitor of that web page, an old system which should not be used again. Although HTML5 seems to want to reimplement a lot of ActiveX-like functionality again, this is not what you want.
If you create a C# application or service that uses the SerialPort class to talk to your PIC, and use for example a WCF service to accept commands over the internet.
You can then create a web page that lets the user issue commands, while the back end of the web page calls the WCF service to send the command to the PIC.
You could build a website or a webservice which runs on the computer with the PIC board. This website would allow you to send commands to the local attached board.
If you have got a .NET SDK for your board you should be able to wrap all the commands in the service or website.
Might look at something like this product http://www.virtualserialport.com/products/serial-over-ethernet/, if you want to make it look like a local serial port. If that's not necessary, I'd write a service that listened on a socket and simply sent the serial data between the socket and the serial port.
Related
I want to have the app i am creating to communicate with my personal android device. As in, my application will be monitoring something on my server, and when something changes it needs to somehow send an option to act or ignore to my phone, and my personal reply (Yes/No) should be send back to the server.
I don't mind any specific protocols. Anything which does not require an app running actively on my phone would be nice, but i am not that great with android native development so if it can be done it should be relatively simply to achieve.
My own idea would be to actually implement Email somehow. So my phone could get an email on my google account (which in turn creates a notification), to which i would send a reply email with my reply. Which in turn will be read out on my server.
The bad part is that i would have to actually open gmail and type out a short message to send back as a reply. So anything easier then that would be a great thing.
I have seen newer android 6 apps use custom buttons in notifications in order for the app to act on, but i have no clue how hard those are to implement and rig to my reply.
Please note that this application is probably nothing that will go public. So i am not going to bother to worry about load or efficiency in the end of it. Since it will be just me and my server.
Any input would be greatly appreciated. The most convenient/easy-to-use method will be marked as the answer.
I think...u can use xml-rpc " http://xmlrpc.scripting.com " for communicating with your server and android app.
I used it in my personal project and found iI to be useful.In my case,I used wordpress as framework so any new updates in my server is notified by this protocol.
My group in the university are working on a project, which includes us making a C# program. We have a vision of making a server side console program that is constantly calculating data and then make a client side program that can fetch the data from our server side program. The client side program will then be able to display the data and the user is able to navigate forth and back around the data. Both of these programs will be run on the same computer solely for exercise purpose.
I am wondering how I can get data from the server side program and be able to display it on the client side program.
If both client and server are always on the same machine, there is no need at all to use WCF or Sockets. You can use named pipes for the interprocess communication.
If you're trying to do a more serious client/server application, I recommend you to try Redis which provides a lot of remote features like pub/sub and caching, so you'll avoid reinventing the wheel.
As mentioned in the comments that sounds like you would like to create a "server" like application which you could do with WCF.
http://tech.pro/tutorial/855/wcf-tutorial-basic-interprocess-communication
There are also some workarounds if you wish to do so, using a Database or use a folder containing Text Files,that would include a folder watcher, which you than read, but they are not that elegant.
You can get data to the client program by configuring it by using web.api self hosting. Here is a great link. The server app can be configured to use the same thing. They can both listen and answer one another.
http://www.c-sharpcorner.com/UploadFile/b1df45/Asp-Net-web-api-self-hosting/
Why don't you give ASP.NET Web API a chance?
You'll be creating a REST API that not only a C# program can talk to (any language/implementation - even another server) can talk to your server as long as the end point is correct (in your case would be your IP address and port number) & of course, you don't need both programs to be on the same computer as well :)
I am creating a "tracking system" for my android phone. Basically, the phone would transmit it latitude/longitude to a C# program that will receive the coordinates and display it on a map. I managed to get the phone's latitude/longitude coordinates but I need a way to transmit that data to my C# application running in my PC. I know my way around C# and Java but never really got into network programming. Is there a way to do this ?
I'd look into C# Webservices, very powerful. The communication protocol is SOAP (Simple Object Access Protocol) which is a popular and well supported standard.
Good starting reference: Your first C# Web Service
I can't speak to the C# side of it, but if you write a C# server to receive post requests, the Apache HttpClient makes it relatively simple to send requests. There are a bunch of other questions on SO that will help with setting up the client side on your phone if you poke around a bit.
You have different way to do it.
The first is to send data over the cloud to interact through distant server. So the both devices have to be connected to Internet
The second id to send the data over a local network so the data have to be on the same network and have to share their IPs
The third is to use adb forward which allows to build a socket connection between the 2 devices over a USB cable. The requirements are that the phone have to be on debug mode I think and that the driver are installed on the PC so the phone is recognized by ADB.
I can add one more by using a Bluetooth connection. Find information here
The correct way to do it would be to build WCF service which allows many different protocols to receive data. This would could be a very powerful solution that can be extended in future.
The fastest and easiest IMO would be to create ASP.NET MVC application, define a POCO Model for your longitude/latitude and create an action that would take your Model as parameter. Then use HttpClient and HttpPost on android to send the data. The trick here is to name the variables in your post request same as ones you define in your C# Model.
I am trying to create a program that will be passed input data from events a user fires from a webpage on their browser. I am aiming at google-chrome currently with the program being in either java or C#. I know this is possible because Spotify does this, so does the Battlefield 3 PC gui. How can I go about doing this? Does the user need to install an extension or can I get that information straight from google-chrome? Note: The webpage is not being run on localhost.
You're going to want to look into web sockets. Web sockets are just cool. I got a huge grin on my face the first time I got demo working. :D
Here's a tutorial that helped me out:
http://www.developerfusion.com/article/143158/an-introduction-to-websockets/
You can create a socket listen in your appilcation then connect to it from javascript, passing whatever data you desire. It's nicer then ajax as it's a persistent open connection and you don't have the overhead of http calls.
I have a C# .NET application listening on a specific port for data (SocketServer).
Using Android, I would like to connect to that SocketServer and send text data to it. I do not know where to get started - sample code would be great.
Take a look at TCP .NET/C# Server with Java client?.
Other than that, you could always recode your server into a REST service, and then anything can communicate with it. But I know this isn't a good answer as I'm sure you don't want to recode the server.