barrett@jhunix.HCF.JHU.EDU (Dan Barrett) (02/26/91)
I have written a MIDI program that opens the serial port in shared mode. I would like to allow this program to be run multiple times simultaneously. The program can be used for reading or writing MIDI, but not both. (Which is why I want multiple copies to be run.) However, the SCMD_SETPARAMS command (to set baud rate, etc.) will fail if another process has any pending reads on the serial port. This is a problem if I try to run several copies of my program! The SCMD_SETPARAMS fails on the invocation of the second copy. So here's the question. How can I have a program that is watching the serial port for reads, and still start up a second program that needs to execute SCMD_SETPARAMS? Or is there another way to accomplish what SCMD_SETPARAMS does? I am doing this: Midi->io_SerFlags = SERF_RAD_BOOGIE; Midi->io_Baud = MIDI_BAUD_RATE; Midi->io_ExtFlags = 0; Midi->IOSer.io_Command = SDCMD_SETPARAMS; if (DoIO((struct IORequest *)Midi) != 0) Error(...); Of course I don't want two different trying to read the serial port at once. But I would like to have a "reader" and "writer" program existing simultaneously. The only way I can do it now is to run the "writer" program first (no pending writes) and then the "reader". I don't want to be forced to run these programs in any particular order. Thanks for any advice. Dan //////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ | Dan Barrett, Department of Computer Science Johns Hopkins University | | INTERNET: barrett@cs.jhu.edu | | | COMPUSERVE: >internet:barrett@cs.jhu.edu | UUCP: barrett@jhunix.UUCP | \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/////////////////////////////////////
rick@tmiuv0.uucp (03/01/91)
In article <7649@jhunix.HCF.JHU.EDU>, barrett@jhunix.HCF.JHU.EDU (Dan Barrett) writes: > I have written a MIDI program that opens the serial port in > shared mode. I would like to allow this program to be run multiple > times simultaneously. The program can be used for reading or writing > MIDI, but not both. (Which is why I want multiple copies to be run.) > > However, the SCMD_SETPARAMS command (to set baud rate, etc.) > will fail if another process has any pending reads on the serial port. > This is a problem if I try to run several copies of my program! The > SCMD_SETPARAMS fails on the invocation of the second copy. > > So here's the question. How can I have a program that is watching > the serial port for reads, and still start up a second program that needs > to execute SCMD_SETPARAMS? Uh, this may seem silly, but why don't you have the first program open up a message port. Additional invocations of the program could send their serial port configuration requests to this message port, and the first program will take care of it when the messages aren't pending. In fact, all I/O to the serial port could be handled by the first program. That might (note I said "might") make the additional invocations a bit smaller, to boot. With the multitasking and message ports available, why reinvent the wheel with each program. [...] > Of course I don't want two different trying to read the serial port at > once. But I would like to have a "reader" and "writer" program existing > simultaneously. The only way I can do it now is to run the "writer" > program first (no pending writes) and then the "reader". I don't want to > be forced to run these programs in any particular order. The scheme I just mentioned would remove the need to run programs in any particular order, since the first one (call it the "master") would handle all the serial port I/O and could arbitrate between the requests. The second and additional invocations would first check for the existance of the message port. If they find it, they know that there's a master program running. If not, then it has to become the master. .--------------------------------------------------------------------------. |[- O] Rick Stevens | | ? EMail: uunet!zardoz!tmiuv0!rick -or- uunet!zardoz!xyclone!sysop | | V CIS: 75006,1355 (75006.1355@compuserve.com from Internet) | | | | "Everybody has to deviate from the norm...." | | - Rush | | "I guess that makes me a deviant!" | | - Me! | '--------------------------------------------------------------------------`