Thread: triggering another program to run using serial port

  1. #1
    Registered User
    Join Date
    Jun 2009
    Posts
    3

    triggering another program to run using serial port

    hello, is it possible that when i run a program on computer A, it will trigger the serial port of computer B so that another program in computer B will run? The computers are connected by a null modem cable and both programs are written in C++ language and is running in a console application.

    The programs are actually a kind of text file transferring between two computers where computer B will read a content from an existing textfile in that computer and send it line by line untill the end of line to computer A and exits itself. Computer A will log the textfile content into a newly created textfile.

    The program is currently working but i have to run the program in computer A first which will start polling for an input and then i go to computer B to click and run the program so that it will start transferring.

    My question is, can i do it in a way that when i run the program in computer A, it will automatically trigger the program in computer B to run without having to click on the program in computer B to run? If it is possible, how can i do it in c++? Does the program in computer B have to be in a sleep mode? I can paste the code for the programs in computer A and computer B if needed. Thanks!

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    what platform are you developing this program for? windows? linux? the way to do it is very different for each. either way, a daemon (linux/unix) running as root or a service (windows) running as the local system account would be where I'd start. have the daemon/service communicate with the port and write another program that uses IPC (interprocess communications) to run at the user level and control the service/daemon.

  3. #3
    Registered User
    Join Date
    Jun 2009
    Posts
    3
    Quote Originally Posted by Elkvis View Post
    what platform are you developing this program for? windows? linux? the way to do it is very different for each. either way, a daemon (linux/unix) running as root or a service (windows) running as the local system account would be where I'd start. have the daemon/service communicate with the port and write another program that uses IPC (interprocess communications) to run at the user level and control the service/daemon.
    the program is running in a windows platform. i am not sure how to write the program for it to run at user level and control the service, can you guide in this?

  4. #4
    Registered User
    Join Date
    Aug 2006
    Posts
    100
    Quote Originally Posted by infineonintern View Post
    My question is, can i do it in a way that when i run the program in computer A, it will automatically trigger the program in computer B to run without having to click on the program in computer B to run? If it is possible, how can i do it in c++? Does the program in computer B have to be in a sleep mode? I can paste the code for the programs in computer A and computer B if needed. Thanks!
    At some point, you will simply have to start 'program B', and probably leave it running all the time waiting for input.

    You can't just simply 'Send Commands' to a serial port and expect something to happen, unless a program is actively watching the port. In fact, with no client program running on 'computer B', the serial port will not even be open.

    Auto-launching the client in user mode, and leaving it in the background is one possible solution, but if you need it to do something even if nobody is logged on, it has to be a system level service most likely. (on Windows)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. FTP program
    By jakemott in forum Linux Programming
    Replies: 14
    Last Post: 10-06-2008, 01:58 PM
  2. HELP with storing serial port data into txt file
    By inmaterichard in forum C Programming
    Replies: 2
    Last Post: 04-02-2008, 02:20 AM
  3. Can't Read From Serial Port
    By HalNineThousand in forum Linux Programming
    Replies: 14
    Last Post: 03-20-2008, 05:56 PM
  4. Input via the serial port for a C program
    By Anthony in forum C++ Programming
    Replies: 2
    Last Post: 07-11-2005, 02:19 PM
  5. Serial Port problems
    By BeBu in forum Linux Programming
    Replies: 1
    Last Post: 04-01-2005, 08:18 AM