Fog Creek Software
Discussion Board




Anyone here a modem guru?

I've written software to manage a modem (standard USR internal type) - it's using an MSCOMM-style component to handle answering calls, authenticate users, receive files, etc.

It works fine on my system, dialling in from my laptop, but on the production system it answers, connects, and my traces indicate it's sending the "Username: " string, but nothing shows up on the client session. Then it looks like it "gets unstuck" when the connection's dropped, almost like the string is sitting in a buffer somewhere. (I've dialled down the UART settings to 1 each...)

Does this sound familiar to anyone? I'm completely stumped...

Philo

Philo
Sunday, July 20, 2003

I doubt the data is stuck between the modems: more likely to be stuck inside the device driver, received by the device driver but not retrieved into the application (or stuck in the receiving modem because the receiving modem has been flow-controlled by the receiving UART, though this is improbable on Win32 where the device driver and not you controls the UART flow control, assuming that the modem and the UART are set for hardware and not software flow control ).

You say "MSCOMM-style" ... using the actual MSCOMM component from .NET is described in http://news.com.com/2100-1029-990612.html?tag=fd_top ... if your problem is that the OnComm event isn't being fired, can you 'poll' to see whether InBufferCount>0 even if the event hasn't been fired?

If you're using the http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvssamp/html/vbcs_usingthecomportinvbnet.asp "sample", beware that I've found MS sample code to be much buggier than their O/S code.

I'm trying to guess how MSCOMM is implemented ... maybe it would help to close-and-then-reopen the port as part of your init sequence, after you install your OnComm event handler?

I personally never used MSCOMM, I used the Win32 API instead; my first thought was the SetCommTimeouts() API, and my next was that you should call ClearCommError() before each call to ReadFile().

I don't know how much modem init stuff is done for you. When I opened a COM port with a real modem, the first thing I would do is send "AT\n" command and expect an OK response from the modem. Then you have to send commands like "ATA" to persuade the modem to answer the incoming call ... and I expect to receive some kind of "CONNECT" string before I begin to receive user session data ... in other words I have already established two-way communication with the modem before getting into end-to-end session data transfer.

Christopher Wells
Sunday, July 20, 2003

Boy, it sure sounds like flow control issues to me.

Brad Wilson (dotnetguy.techieswithcats.com)
Sunday, July 20, 2003

I don't *think* it's flow control - prior to connecting I send several commands to the modem and get an OK to each.

Since the code had a habit of leaving the modem off-hook when I stopped it, I added an ATH0 to my initialization - the modem stops responding after *that* command. Now I'm thinking there's something about the modem that throws it out of command mode whenever the hook state changes - does that make sense?

Philo

Philo
Sunday, July 20, 2003

I had a similar issue using mscomm.  Xon/xoff alone worked ok with a laptop modem but with an external modem it needed the handshaking to be both x/on/xoff AND hardware.

Dilettante
Sunday, July 20, 2003

...or it could be a bad modem. Dammit.

Philo

Philo
Sunday, July 20, 2003

I used a modem string like AT&C1&D2E0H0Q0S0=0V1 (hardware flow control, text responses from the modem, drop the connection when DTR goes down, don't auto-answer, etc.).

ATH0 can cause the modem status register pins to flicker, which results in a MSR event, which can impede I/O until you call ClearCommError() ... however I don't see how ClearCommError() (a Win32 API) is related to the MSCOMM API ... I'm guessing that MSCOMM should call ClearCommError() automatically if you have an OnComm event handler installed.

Be careful not to send a second AT command until it has responded to the first. Closing the serial port drops DTR ... init the modem as above, and keep the port closed for a significant fraction of a second before reopening it, is a reliable way to force the modem into command mode. Following my guess about ClearCommError(), try it with and without having an OnComm event installed (instead of OnComm you could just poll/read data from the modem once every 250msec or so). If it works without onComm and you want to use OnComm, try putting a 300msec Sleep before and after installing your OnComm event handler.

You might find one of the http://www.google.ca/search?q=%22serial+port%22+monitor+NT&hl=en&ie=ISO-8859-1 products useful.

Christopher Wells
Monday, July 21, 2003

  i have to put as my company name as Modem name  no i'm installing Stanard modem ...i try to change name in Registery ...i con't reach that ....
how i can change in property page .......i'm using my Inf File i have mention my modem name as string name ...i t not get Effect ...

velu
Thursday, July 01, 2004

*  Recent Topics

*  Fog Creek Home