Modem Driver

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
GPF
DC Developer
DC Developer
Posts: 529
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Wed Oct 17, 2001 7:44 pm
Location: Texas
Has thanked: 0
Been thanked: 0
Contact:

Modem Driver

Post by GPF »

Has anyone been able to use the modem driver in KOS?

I compiled the example, and burned it to cd, hooked my phone line from my modem on my pc to the modem on the DC and fired up my terminal program and typed ATA, and I never was able to get connected.

Any one hear of anyone ever getting it to work?

Thanks
Storminator16
DCEmu Veteran
DCEmu Veteran
Posts: 850
Joined: Mon Sep 01, 2003 11:12 am
Location: NC/Iraq
Has thanked: 0
Been thanked: 0
Contact:

Post by Storminator16 »

Wasn't able to work before, you might here something interesting in the near future.

http://www.dcemulation.org/phpBB/viewtopic.php?t=44016

There is another thread on C'Vision in which Dan says he was going to work on hooking up a modem last night, but I can't seem to log on the damn site at the moment :/ I believe it was in the "Sad News" thread in the Dreamcast Disscussion forum.
GPF
DC Developer
DC Developer
Posts: 529
Joined: Wed Oct 17, 2001 7:44 pm
Location: Texas
Has thanked: 0
Been thanked: 0
Contact:

Post by GPF »

Yeah, I saw your message earlier, thats why I finally decided to try the modem driver :) I was just looking to see if anyone has been able to use the modem driver example in kos? Do I need a phone line simulator to add voltage to the line? I have seen the question asked on the original thread over on Boob but no responses that anyone other the author of the driver to get it to work.

thanks
itoledo
DC Developer
DC Developer
Posts: 47
Joined: Tue Aug 26, 2003 1:54 pm
Location: Santiago, CL
Has thanked: 0
Been thanked: 0
Contact:

Post by itoledo »

at last with my intel modem, i needed to use the line simulator. didn't work without it.
itoledo
DC Developer
DC Developer
Posts: 47
Joined: Tue Aug 26, 2003 1:54 pm
Location: Santiago, CL
Has thanked: 0
Been thanked: 0
Contact:

Post by itoledo »

sorry, double post...
GPF
DC Developer
DC Developer
Posts: 529
Joined: Wed Oct 17, 2001 7:44 pm
Location: Texas
Has thanked: 0
Been thanked: 0
Contact:

Post by GPF »

Did you build the line simulator or did you buy one ? If you built it do you have schematics? I saw a line simulator that used a 9 volt battery and a 150 Ohm resistor, you think that would work?

thanks
itoledo
DC Developer
DC Developer
Posts: 47
Joined: Tue Aug 26, 2003 1:54 pm
Location: Santiago, CL
Has thanked: 0
Been thanked: 0
Contact:

Post by itoledo »

i build one.
there's a whole site dedicated to connecting the DC to a PC...
http://consolevision.com/members/mterlouw/

good luck :)
GPF
DC Developer
DC Developer
Posts: 529
Joined: Wed Oct 17, 2001 7:44 pm
Location: Texas
Has thanked: 0
Been thanked: 0
Contact:

Post by GPF »

Thanks for the info. I checked out that web site and saw that it says that "Some Dreamcasts were shipped with modems that rely on the voltage of a live phone line to work properly. There is a workaround for this, the so-called Line Voltage Simulator."

So I will check my other 2 dreamcast modems and see if they work, and if not I will build the phone line simulator.

Thanks
GPF
DC Developer
DC Developer
Posts: 529
Joined: Wed Oct 17, 2001 7:44 pm
Location: Texas
Has thanked: 0
Been thanked: 0
Contact:

Post by GPF »

Tried my other modems and found one that works, everything is identical to the three modems all have the same serial number, etc. Except one of them had a canadian flag sticker on it, and that one allowed me to connect to my dreamcast with the kos modem driver, with only a phone cord - 100 feet from the computer room to the living room tv :)

Since I don't have a serial cable, I changed the kos modem example to print the text it received to the screen with the bios font, didn't work correctly , except everytime I sent a line from my pc to the dc it drew the 1st character I typed and then a bunch of garbage, then on the 2nd line it would print the second character I typed and a bunch more garbage,etc.

I need to store up the characters untill getting a carriage return and append all of the characters into a string and print that to the screen I guess.

Now I need to figure out how to send text back from the dreamcast to my pc and build a chat client or something like it.
GPF
DC Developer
DC Developer
Posts: 529
Joined: Wed Oct 17, 2001 7:44 pm
Location: Texas
Has thanked: 0
Been thanked: 0
Contact:

Post by GPF »

Now I need to figure out how to send text back from the dreamcast to my pc and build a chat client or something like it.
Well I got that chat client figured out, if you have a dreamcast keyboard it will allow you to type back to the pc terminal client, otherwise it just acts like an autochatter, sending back what every it is sent.

I am having a problem though, after it connects, for about 30 secs I get garbage character that appear in the pc terminal window, then after that it works correctly I need some help figuring out some kind of state machine so that as soon as the garbage clears up I can sync up with the pc. Or maybe its an initialization string I have to send, Im stuck at this part.

I have attached the code if anyone wants to try it out, or let me know someplace to post it and you can try it out.

--------
All you have to do is hook your pc modem to your dc modem -- Notice some DC modems require voltage on the phone line to work, so you might need a different modem or to build a phone line simulator.

Then fire up a terminal program on your PC and type "ATA" to answer the dreamcast, and as soon as it gets connected start typing and the text should display on the Dreamcast screen and if you have a keyboard attached to your dreamcast, you can type back to yourself, otherwise it will just autoreply back with what ever you type on the PC.

Troy

Code: Select all

/* Example program */

#include <stdio.h>
#include <kos.h>

int startButtonPressed(void)
{
    cont_cond_t controller;

    cont_get_cond(maple_addr(0, 0), &controller);

    return !(controller.buttons & CONT_START);
}

int main()
{
    int			bytesRead = 0;
    int			bytesWritten=0;
    unsigned long          i;
    unsigned char data[1024];
   	int k, o, x = 20, y = 20+24;
   	uint8 mkb;
   	while(1)
	{
		for (y=0; y<480; y++)
		for (x=0; x<640; x++)
		{
			int c = 2;
			vram_s[y*640+x] = c;
		}

		o = 20*640 + 20;
	
		if (!modem_init())
		{
		   printf("modem_init failed!\n");
		   return 1;
		}

		modem_set_mode(MODEM_MODE_DIRECT, MODEM_SPEED_V34_AUTO);
    
		bfont_draw_str(vram_s + o, 640, 1, "Waiting for a connection"); 
		printf("Waiting for a connection\n");
    
		while (modem_is_connecting())
		{
			  if (startButtonPressed())
			  {
				 printf("Connection aborted\n");
				 break;
			  }
		}
		bfont_draw_str(vram_s + o, 640, 1, "Making a connection      "); 
		
		if (modem_is_connected())
  		{	
   				 bfont_draw_str(vram_s + o, 640, 1, "CONNECTED                 "); 
   		}
       		
		while (!startButtonPressed())
		{
			
			if (modem_is_connected())
			{
			  if (modem_has_data())
			  {
				 bytesRead = modem_read_data(data, 1);
             
				 if (bytesRead > 0)
				 {
					for (i=0; i<bytesRead; i++)
					{
						 printf("%c", data[i]);
						 bfont_draw(vram_s + y*640+x, 640, 1, data[i]);
						 x += 12;
						 if (data[i] == '\r')
						 {
							   x = 20;
							   y += 24;
						 } 
						 mkb = maple_first_kb();
            		     if (!mkb)
            		     {
            		     	//no keyboard detected act as an autochatter
            		     	bytesWritten = modem_write_data(&data[i], 1);
           		     	 }                      
					}
				 }

			 }
         	
         	
			 if ( ( k = kbd_get_key() ) != -1)
			 {
         		if (k > 0xff)
					printf("Special key %04x\n", k);
				
				if (k != 13)
   				{
   					bfont_draw(vram_s + y*640+x, 640, 0, k);
					x += 12;
				}
   				else
      			{
      				x = 20;
					y += 24;
				}
			
    			if (k == 27)
          		{
          			printf("ESC pressed\n");
          			break;
				}
				char a= (char)k;
					bytesWritten = modem_write_data(&a, 1);
				if (k == 13)
   				{
   					char f='\n';
   					bytesWritten = modem_write_data(&f, 1);
				}
			 
			}
			
			if  (x >=630)
			{
				x = 20;
				y += 24;
			}
			
			if (y >= 460)
			{
				for (y=0; y<480; y++)
				for (x=0; x<640; x++)
				{
					int c = 2;
					vram_s[y*640+x] = c;
				}
				x = 20, y = 20+24;
			}
   		  }
   		  else
   		  {
   		  		bfont_draw_str(vram_s + o, 640, 1, "Connection failed       ");
		   		printf("Connection failed\n");
		   		break;
          }
		}

 
		bfont_draw_str(vram_s + o, 640, 1,  "Disconnecting.."); 
		printf("Disconnecting..\n");
		modem_disconnect();
	}
    return 0;
}
Sanchez
DCEmu Ex-Admin
DCEmu Ex-Admin
Posts: 1098
Joined: Wed Oct 17, 2001 7:44 pm
Has thanked: 0
Been thanked: 0

Post by Sanchez »

Not that it matters much for this conversation, but for your video clearing code, try vid_clear(r, g, b). Heck of a lot easier than looping through each time....
"This is worse than when the Raccoon got in the copier!"
doragasu
DCEmu Cool Poster
DCEmu Cool Poster
Posts: 1048
Joined: Thu May 16, 2002 5:01 pm
Location: Madrid, Spain
Has thanked: 0
Been thanked: 0

Post by doragasu »

It would be great to use the DC modem in the same way coder's cable can be used.
Storminator16
DCEmu Veteran
DCEmu Veteran
Posts: 850
Joined: Mon Sep 01, 2003 11:12 am
Location: NC/Iraq
Has thanked: 0
Been thanked: 0
Contact:

Post by Storminator16 »

GPF, if you see this eventually, there are some questions wanted to be asked to you in #consolevision (on irc.xelium.net). a lot of people really want to try this out for themselves.
GPF
DC Developer
DC Developer
Posts: 529
Joined: Wed Oct 17, 2001 7:44 pm
Location: Texas
Has thanked: 0
Been thanked: 0
Contact:

Post by GPF »

Well I stopped by the chat room but I think I missed you by about 4 hours, I'll try again later or tommorow, if I can connect from work. Otherwise put you questions on here and I'll reply at work tommorow.

Troy
Storminator16
DCEmu Veteran
DCEmu Veteran
Posts: 850
Joined: Mon Sep 01, 2003 11:12 am
Location: NC/Iraq
Has thanked: 0
Been thanked: 0
Contact:

Post by Storminator16 »

It wasn't me with the questions: it was Xylene. He's wondering how you got it to work, and did you use a custom DC-Tool/DC-Load.
GPF
DC Developer
DC Developer
Posts: 529
Joined: Wed Oct 17, 2001 7:44 pm
Location: Texas
Has thanked: 0
Been thanked: 0
Contact:

Post by GPF »

I have hacked some of the dc-tool code so that it sends 'ATA' and some handshaking code to my dreamcast chat program listed above and can connect with dc-tool to my modem code.

But I still have to implement the upload and execute code, probably will cut and paste most of it from dc-load.

I tried to just move the modem code into dc-load souce and just hack the serial code to call the modem functions instead, but the modem driver relies so much on KOS code that I haven't been able to just insert the code.

Troy
Alexvrb
DCEmu Ultra Poster
DCEmu Ultra Poster
Posts: 1754
Joined: Wed Jul 17, 2002 11:25 am
Has thanked: 0
Been thanked: 0

Post by Alexvrb »

doragasu wrote:It would be great to use the DC modem in the same way coder's cable can be used.
Even though its much slower? Probably limited to 33.6k. I don't know if you can get faster speeds by having a V.92 modem in your PC or not. But even if you could it'd be around 48k max, which is less than half the speed a coder's cable operates at.

There's really no advantage other than the fact that you don't need a coder's cable. Which I guess would be fine for just starting out. But you'd need a modem in your PC and it looks like for many a line simulator as well.
ragnarok2040
DC Developer
DC Developer
Posts: 462
Joined: Wed Oct 17, 2001 7:44 pm
Has thanked: 0
Been thanked: 0

Post by ragnarok2040 »

Alex, you'd need a digital modem in order to reach v.90 speeds. We could still do the burn and test, but the cable provides us a way to get diagnostic/debug information when we test it out, as printf functions don't require a lot of bandwidth.

The line simulator is a snag, but what if instead of having the DC modem originate, we do it in reverse and have the DC modem answer, maybe by sending a ring or whatever?
GPF
DC Developer
DC Developer
Posts: 529
Joined: Wed Oct 17, 2001 7:44 pm
Location: Texas
Has thanked: 0
Been thanked: 0
Contact:

Post by GPF »

I haven't tried to connect the other way, from the dc to the pc instead of the pc answering the dc. The modem driver provides the functionality, but I haven't tried it.

The line simulator is not much more than a 9 volt battery and a couple of resistors attached to a phone jack. Probably could be built for a couple of bucks.

Hopefully soon I will have some more time to work on that. I have been to busy lately with work.

ragnarok any luck on getting the modem to dial out?
multiverse
Insane DCEmu
Insane DCEmu
Posts: 102
Joined: Sun Oct 12, 2003 10:31 am
Has thanked: 0
Been thanked: 0

Post by multiverse »

GPF wrote:I haven't tried to connect the other way, from the dc to the pc instead of the pc answering the dc. The modem driver provides the functionality, but I haven't tried it.

The line simulator is not much more than a 9 volt battery and a couple of resistors attached to a phone jack. Probably could be built for a couple of bucks.

Hopefully soon I will have some more time to work on that. I have been to busy lately with work.

ragnarok any luck on getting the modem to dial out?
if anyone wants the schematics for the line simulator theyre right here

http://www.consolevision.com/members/mt ... onnect.htm
Under-Developed Development - Now with a dash of Dreamcast!
http://www.freewebs.com/uddev/
Image
Post Reply