I'm looking into developing software that would be able to listen for commands sent across the COM1 serial port, interpret them and send back unique data based off of that command.
ex) if the listener reads a command sent as 0x05, it would send back 0x10.
We currently have software in C# that sends commands across COM1 to our hardware products, but during development we are not guaranteed to always have hardware available to test on and ensure the GUI controls are functioning properly. This listener would help alleviate that issue. My coworker has been refining a python script that utilizes the Pyserial package which I plan on using to handle command protocol.
So ultimately, I am expecting my C# application to have COM1 open and sending commands while the listener program reads any data sent, interprets it and sends back the correct response. Is this the correct way of going about this?
com0com creates virtual com ports on the computer so you can run both programs on the same computer without multiple com ports and loopback cables. This could be handy when doing this kind of things.
Is this the correct way? It sounds to me like it would be easier to add a emulate mode to the C# software when it returns it's own answers without making a complex thing with serial ports and another piece of software that needs maintaining.
I have 2 gprs/gsm modems with me at the moment one of them is huawei and the other is a prolink modem. I have no problem sending or receiving SMSes via AT Commands. However I am trying to receive automatic notification using this command AT+CNMI and I am not able to get it to work but when I try this command the modem replies with ok with no errors.
Procedures that I have performed so far
Tried numerous combination for the AT+CNMI commands 2,1,0,0,0, 2,2,0,0,0 and etc but to no avail
I have set the preferred message storage to sim card and I am able to receive message and extract it as well using various AT commands.
I tried in hyperterminal as well as using C sharp but to no avail. The built software that comes with the modem are able to receive the notification. Can someone guide me on this.
Many of these types of devices use different commands. Some use proprietary commands. Since it works fine with the included software, I would recommend figuring out how that works.
The easiest way to do this is to fire up some free serial port monitoring software. Once you get it set up, start up the software the device came with and see what commands it sends. Then, you can use those same commands yourself.
I managed to figure out the problem already :) . Basically the modem that i used makes use of several different ports and the new message notification will be received by another port. Problem solved.
I want to hang up after modem finish dialing a phone number.
I can track when modem start dial and when it disconnect. But I can't track dial finished.
I use TAPI for it. I tried C# and C++. But I don't know how to manage it.
When a modem is dialing, it's normally just sitting there waiting for the other end to answer. TAPI can tell you when the dialing starts (because it sends the command to dial) and when the hangup occurs (because the modem reports "NO CARRIER"), and it can tell you when the other modem answers (because then the modem reports that it's connected), but the modem doesn't say when it's done dialing. (So-called "winmodems" might be able to do this, as they're run more by the driver than the hardware in the modem. But it's not something you can really rely on.)
This means that the only way you can really know is to have a modem that can feed the sound on the phone line back in through a mic or line-in or something (which also isn't exactly universal on a modem), and having some software listen for the touch tones and report when it hears a pause.
I have a ticket printer I am trying to send raw print commands to,
I am currently sending the commands by pinvoke to winspool.drv and calling WritePrinter. This is working for most of the commands I am sending, but I cannot get feedback from the printer this way (for example, the printer has a barcode reader on it, I can send them command read barcode but I cannot receive the data back as it is stopped by the windows spooler).
Is there a way to open a USB port and send a byte[] of commands in C#?
Many Thanks
Shaun
You can exchange data over USB in a similar manner as you read/write to a file. Here's an interesting article on that topic.
Using the windows printer driver has some advantages though. Are you sure you want to do this yourself?
Ok, everybody get in your wayback machine. I need to have a phone dial into my computer's 56k modem. I need my computer to have the modem "on" and have an active dialtone.
Here is why:
I have a sump pump alarm that will call me on a pump failure. It only works with a landline. I want to stop paying for my landline to save money and just have my cell. My idea is to intercept the outbound caLL from my sump alarm on my pc's 56k v90 modem. Then I can text message, email,etc... for free.
Does anybody know how to get started? I have found plenty of stuff on how to make outbound calls from my pc, but I want a phone (device) to dial my pc. I think the sump alarm will not dial unless it hears a dialtone.
I prefer a C# or vb6 program, but willing to go with anything. I have some experience working with serial comm devices so I just need to be pointed in the right direction.
Thanks!!!
You're going to need more than a modem in your PC to accomplish what you've described. Both the sump pump and your PC have modems, which are the subscriber end of a telephone "loop". The CO end (Central office in telephony terms) provides functions that you're telephone and both the modems mentioned above.
A big one is the generation of a ring ... this is a relatively high voltage AC signal that actually rang the bell in the old style telephones, but is simply detected in newer phones and your modems. In order for your sump pump's call to be recognized, this ring voltage has to be received at your PC's modem, but the sump pump won't actually generate this tone.
The other ideas presented here (the use of a PABX SOHO switch or connecting the detected signal from the sump pump directly to a I/O port on your PC), I can think of one other option. Somewhere inside the sump pump is a UART chip that does the serial communications to the included modem. If you disconnect the modem from the UART, you have the basics of a serial port, which can be connected to the serial port on a PC (though you may need an interface chip to get the levels right ... see the ICs provided by Maxim).
Good luck!
The easy way: Take a simple PABX (small SOHO kind) to let your alarm call your PC. You can use your PC's modem to wait for a RING from your modem. (Use the System.IO.Ports.SerialPort class to accoumplish this.) You'll need to program your alarm system to call the internal number of your PC.
Once you get a ring, you let your software do the rest.
Another option is a pySerial script written in Python.
You can write a small listener that listens for phone calls from your pump modem. You will need to know some AT commands, which you can look up anywhere online.
import pySerial
ser=serial.Serial('COM4',2400,timeout=1) #replace 2400 with your baudrate
ser.open()
ser.write("ATS0=1\r\n") #picks up after one ring
while(1):
line = ser.readline() #listen in a loop
I used to have a "Telephone Line Simulator" that allowed me to test modem configurations by letting one modem call another through a little black box that simulated the phone company's part of the bargain. Something like that should be easy to find, and would be an easy solution to your problem.
Do you need the sump pump to actually dial?
Can you not just intercept the sump pump's check for the dialtone?
Or better,
maybe there is an electronics friend you have who can wire up a simple device that plugs into the sump pump and checks for a voltage edge that occurs when the pump fails. This is an event preceding or concurrent with the pump actually trying to dial. When this little device detects the edge, it can then trigger something on your PC appropriately. The device might even be able to detect the V change on the telephone line - on the RJ11.
I don't know how familiar you are with electronics, but I almost wonder if your solution could be handled with a mix of software and hardware.
My first thought was to have something like an Arduino hooked up to either the circuit that does the pump failure detection or the phone line and watches for whatever signal the pump sends out. Arduinos are usually hooked up to your computer via serial/usb, and then you can have a piece of software that emails you, tweets at you, or whatever you want.
You could possibly have your modem watch for the pump trying to dial out, but I have no idea how you could do that.
I'd probably keep the two programs separate.
I'd have HyperTerminal (assuming you're on a Windows machine) running against your modem, with ATA or something similar, upon activity, I'd have it write a file.
I'd have another program running as an automated task (like every 30 minutes), looking to see if that file has been changed, and have that trigger a SMS message to your phone.
I'd imagine this would be a simple enough setup that it'd be easy to maintain, yet reliable enough to prevent your house from becoming a pool...