Page 1 of 1
help needed for modem driver
Posted: Sun Nov 16, 2003 5:21 am
by shahzad
i'm trying to implement tcp/ip stack.for this first i need to communicate with modem.
can u please give me some code,link or anything else which u think might be helpful in writing modem driver.
Re:help needed for modem driver
Posted: Sun Nov 16, 2003 7:02 am
by Tim
You might want to think about how you're going to organise your TCP/IP stack first, because that will be a lot harder than talking to the modem via the serial port. Serial port access can be as simple as a couple of routines.
In fact, you might find it easier to set up a test PC with a network card, and get TCP/IP working over a network first. That will minimise the amount of code you'll need to debug, because it will delay the need to write serial port or PPP code until later. You'll still have a lot of work to do, with Ethernet/ARP/IP/UDP/TCP to do, but it will be less.
Re:help needed for modem driver
Posted: Sun Nov 16, 2003 1:26 pm
by shahzad
thanks tim.But still i need to communicate with some communication device (modem etc.) to check tcp/ip over a small network of just two PCs.
Can u please help me with those couple of routines to start communication through modem.
Re:help needed for modem driver
Posted: Sun Nov 16, 2003 1:48 pm
by Tim
The PC serial port is completely standard, and has remained almost the same since the PC was introduced back in the 1980s.
http://www.nondot.org/sabre/os/articles ... onDevices/ should have what you need.
Re:help needed for modem driver
Posted: Mon Nov 17, 2003 6:10 am
by Pype.Clicker
of course, this mainly apply to 'external' modems. Do not expect any support for so-called Winmodems, as they are some kind of poor undocumented digital-to-analogous chips controlled by a closed-source driver in a .DLL file ...
Re:help needed for modem driver
Posted: Tue Nov 18, 2003 11:16 am
by faheem
i've implemented tcp/ip stack in c using one library function to establish connection with modem.
now i'm trying to work that stack as stand alone .for this
i've to code a modem driver.Can anyone give me code to
dial a number using Hayes AT Commands.I'll build rest of driver using that code as hint
Re:help needed for modem driver
Posted: Tue Nov 18, 2003 12:34 pm
by Pype.Clicker
i think you should get a look at the .:QuickLinkz:., especially the serial port programming section.
Re:help needed for modem driver
Posted: Tue Nov 18, 2003 3:48 pm
by Tim
Dialling a number is easy.
Tone dialling:
Code: Select all
serial_write("ATDT");
serial_write(phone_number);
serial_write("\n");
Pulse dialling:
Code: Select all
serial_write("ATDP");
serial_write(phone_number);
serial_write("\n");
Then:
Code: Select all
serial_wait_for_text("CONNECT");
serial_read_line(connect_speed);
printf("Connected at %s bps\n", connect_speed);
Then do your PPP, IP and TCP stuff.
Re:help needed for modem driver
Posted: Wed Nov 19, 2003 12:31 am
by shahzad
in the following nothing is printed on screen,although the modem is set in loop back mode.
i ckecked the code for both com1 and com2.the uart chip on my system is 16550A.
please tell me what's causing the problem.
Code: Select all
#define PORT1 0x2F8
void main(void)
{
int c;
int ch;
outportb(PORT1 + 1 , 0);
/* PORT 1 - Communication Settings */
outportb(PORT1 + 3 , 0x80);
outportb(PORT1 + 0 , 0x03);
outportb(PORT1 + 1 , 0x00);
outportb(PORT1 + 3 , 0x03);
outportb(PORT1 + 2 , 0xC7);
outportb(PORT1 + 4 , 0x0B);
printf("\nSample Comm's Program. Press ESC to quit \n");
do {
c = inportb(PORT1 + 5);/* Check to see if char has been */
/* received.*/
if (c & 1){
ch = inportb(PORT1); /* If so, then get Char */
printf("%c",ch); /* Print Char to Screen*/
}
if (kbhit()){
ch = getch(); /* If key pressed, get Char */
outportb(PORT1, ch); /* Send Char to Serial Port */
}
} while (ch !=27); /* Quit when ESC (ASC 27) is pressed */
}
the code that i used to detect UART is as follows
Code: Select all
void detect_uart(unsigned base)
{
unsigned char i;
outportb(base+2,0x01);
i=inportb(base+2) & 0xc0;
if(i==0)
printf("\nless than 16550");
if(i==0x80)
printf("\n 16550");
if(i==0xc0)
printf("\n 16550A");
}
Re:help needed for modem driver
Posted: Wed Nov 19, 2003 3:48 am
by Pype.Clicker
please post indented code ...
Re:help needed for modem driver
Posted: Wed Nov 19, 2003 4:04 am
by Pype.Clicker
i'm unsure (never programmed an UART), but it looks weird to me that you can send such a long serie of outport() without having a technique to check that the chip has received and processed the last info.
Many I/O cards have a 'received byte' register in which they cache the last byte you sent until it has been processed by the internal logic, and if you modify that byte (with another outport()) before it has been processed (you're usually informed of this by an IRQ or because the 'status' register of the card tells you the card is no longer BuSY), chances are that the operation performed will not be the one you expected...
Re:help needed for modem driver
Posted: Sat Nov 22, 2003 7:16 pm
by shahzad
The code that i posted might be for external modem.
Am i correct or not ?
Is there any material available on programming internal modems.
Please tell me if this code works on external modem because i've only internal modem.
Re:help needed for modem driver
Posted: Sat Nov 22, 2003 7:56 pm
by Tim
There are two types of internal modems:
- Those that install themselves as an extra serial port (they're effectively an external modem without a box). These are rare.
- Winmodems, which rely on a Windows driver to do the work. These are really common.
It's likely that you've got a Winmodem, in which case you won't be able to use it without a Windows driver.
You'll have more success if you buy yourself a simple external modem and use that.
Re:help needed for modem driver
Posted: Sat Nov 22, 2003 11:01 pm
by neowert
When you do the stack, write it for you developing OS, not your kernel. Easier to debug. You can just have intermediate I/O routines that use your development OS's I/O. When you put the code in the kernel, use its I/O routines.
Re:help needed for modem driver
Posted: Sun Nov 23, 2003 3:04 am
by Candy
very generally speaking, if your modem is 56k you have a high chance of winmodem. If it's onboard (laptop etc) I'm pretty sure it is. If your modem cost less than something like 40 euros new, it is very probably a winmodem.
If not all of these, it is not.