Click here to Skip to main content
13,559,479 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi all, I have a C # application that receives data from the serial port and saves mysql, it sends data to the serial port and the answers.

Also I have a website with a WAMP server that allows access from anywhere and send data to the serial port to control the connected device.

I can not connect from PHP to the serial port if it is in use by the application in C #.

Send the data to C # for PHP application, and the application is what is responsible for interacting with the serial port.

My Question:
How I can send parameters to the application C # from PHP and how to make this process it.
Posted 24-Feb-13 2:06am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

There are several approaches, depending on several things. According to what you wrote, you have full access to the server, and you can install and run anything.
A) write your c# app as command line tool, and simply call it from php:[^]
B) You could write/use a sutom extension to php to access the serial port. Look here:[^]
C) If your C# app is a service, or is permanently running, you could use some IPC, like MSMQ to communicate. Look here for php side:[^] and c# side respectively: Using MSMQ from C#[^]
D) Named pipes. Php Side:[^], c# side:[^]

[updated php msmq link + named pipe option]
Santiago-Marco 24-Feb-13 9:53am
A) no es posible ya que la aplicacion esta escrita en visual C#
B) si ejecuto la aplicacion en C# deja el puerto ocupado y no puedo acceder desde PHP

C) The application runs permanently. I think this is a good option, would need more information to implement MSMQ in PHP, C # seems simple, but found no information in PHP.

At the moment only send information PHP and C # only get that information.
ZorgoZ 24-Feb-13 11:57am
Although I don't know Spanish, I am pretty sure you either misunderstood my answer or your question is wrong.
A) Visual C# is no language and no platform - actually there is no such thing. You can write command line application with (not in) Visual Studio any edition that is capable of c#.
B) Yes of course, you can not open a serial port in both. But it was not clear that you must use two separate application. But as it has to run permanently, this is quite obvious.
C) Sorry, I have pasted wrong link for the php side. See update. It is also not a big deal.

And yes, based on what you added, I am pretty sure, MSMQ will be a good solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web02 | 2.8.180527.1 | Last Updated 24 Feb 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100