Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# PHP VisualStudio2010
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.
 
problems:
I can not connect from PHP to the serial port if it is in use by the application in C #.
 
solution:
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
good
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: http://www.php.net/manual/en/function.exec.php[^]
B) You could write/use a sutom extension to php to access the serial port. Look here: http://code.google.com/p/php-serial/[^]
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:
http://pastebin.com/S5uCiP2Z[^] and c# side respectively: Using MSMQ from C#[^]
D) Named pipes. Php Side: http://my.opera.com/zomg/blog/2007/08/29/php-and-named-pipes[^], c# side: http://tech.pro/tutorial/633/interprocess-communication-using-named-pipes-in-csharp[^]
 
[updated php msmq link + named pipe option]
  Permalink  
v3
Comments
Santiago Marco at 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.
Zoltán Zörgő at 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
0 OriginalGriff 278
1 Nguyen.H.H.Dang 230
2 Maciej Los 205
3 Peter Leow 195
4 arvind mepani 187


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