This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Getting SLIP lwIP to work against Windows


After a bit of fiddling, I got lwIP SLIP to work w/eCos and Windows.


One thing that threw me off was an option in Windows that is called "Show terminal window".
I thought this was a progress window, but it is not.

It allows the user to manually send off textual commands(normally to a modem) as a prelude
to the SLIP protocol.

- Either disable it, or
- Click continue once everything is ready to launch the SLIP protocol.


Before launching the SLIP protocol, I added a bit of code to handle the "Windows prelude".


   cyg_io_handle_t handle;
	void sendStr(const char *str)
	{
		cyg_uint32 len=strlen(str);
		cyg_io_write(handle, str, &len);
	}
	
	bool checkStr(const char *str, const char *str2, int max)
	{
		int len=strlen(str);
		if (len>max)
		{
			len=max;
		}
		return strncmp(str, str2, len)==0;
	}




	Cyg_ErrNo err;
    	err = cyg_io_lookup( "/dev/ser0", &handle );

		char buf[100];
		cyg_uint32 pos=0;
		
		while (pos<sizeof(buf))
		{
			// wait for string.
			cyg_uint32 len=1;
		    err = cyg_io_read( handle, buf+pos, &len );
			pos++;
		    
			if (checkStr("ATDT\r", buf, pos))
			{
				sendStr("CONNECT\r");
				break;
			} else if (checkStr("AT", buf, pos)&&(buf[pos-1]=='\r'))
			{
				sendStr("OK\r");
				pos=0;
			} else if (checkStr("CLIENT", buf, pos))
			{
				sendStr("CLIENTSERVER");
				break;
			}
		}

// At this point Windows is speaking SLIP
		
		lwip_init();	
		sys_thread_new(tcpecho_thread, (void*)"tcpecho",7);  


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]