EmbeddedRelated.com
Forums
Memfault State of IoT Report

Using Static IP mode

Started by Steve January 31, 2005
I'm sorry, I missed your question. The answer is yes,
I only call sock_init() once.

I have one call to ifconfig() before sock_init() and
one call to ifconfig() after sock_init().

The second ifconfig call is not executed until
pd_havelink() returns true, indicating the Rabbit is
connected to a network. This works fine for DHCP. But
pd_havelink() never returns true when in static IP
mode. So I'm in the process of re-writing my ethernet
initialization procedure to remove the pd_havelink
call when in Static IP mode. I'd don't know if that
will make a difference, but its the only think I can
see that is different between the two modes.

Steve --- Bob Hohentanner <bhohentanner@bhoh...> wrote:

> Steve,
>
> Did you get my question about where you have
> your sock_init relative
> to the ifconfig calls? You only call sock_init once
> right?
>
> ________________________________
>
> From: Steve Trigero [mailto:seecwriter@seec...]
> Sent: Tuesday, February 01, 2005 4:16 PM
> To: rabbit-semi@rabb...
> Subject: Re: [rabbit-semi] Using Static IP mode > Changing the address caused pingme to work.
>
> But that doesn't explain why I can't ping my own
> program when in Static IP mode. DHCP works fine.
>
> Steve > --- Arlen Fletcher <arlenf@arle...> wrote:
>
> > Change the IP address on your PC to 10.10.6.1 and
> > set the netmask to
> > 255.255.255.0.
> > Reboot the PC. Try the pingme program again and
> let
> > us know the
> > results.
> >
> > Arlen
> >
> > On Feb 1, 2005, at 11:05 AM, Steve Trigero wrote:
> >
> > >
> > > I tried sample program pingme.c and it works,
> sort
> > of.
> > > At least the link light on the hub lights up. I
> > tried
> > > pinging it but I get error message "Destination
> > > unreachable". I suspect it has to do with the
> > default
> > > IP address used, 10.10.6.100. My PC is still at
> > > 192.168.100.2.
> > >
> > > I notice that pingme.c does not call ifconfig().
> > It
> > > just calls sock_init() and tcp_tick(). Or is
> there
> > > some code buried in one of the DC libraries that
> > does
> > > this?
> > >
> > > Steve
> > >
> > > --- Bob Hohentanner <bhohentanner@bhoh...>
> > wrote:
> > >
> > >> Gateway is not needed if it's just your PC and
> > the
> > >> Rabbit connected to
> > >> the hub.
> > >>
> > >> Yes, the sample static.c is for a web server,
> but
> > >> uses a static address
> > >> and you can use this sample to see if it's your
> > >> hardware or firmware
> > >> that flakey
> > >>
> > >> ________________________________
> > >>
> > >> From: Steve Trigero
> [mailto:seecwriter@seec...]
> > >> Sent: Tuesday, February 01, 2005 1:24 PM
> > >> To: rabbit-semi@rabb...
> > >> Subject: RE: [rabbit-semi] Using Static IP mode
> > >>
> > >> My IT guys are asking about the gateway setting
> > in
> > >> the
> > >> Rabbit. They seem to think that this is very
> > >> important
> > >> and that if its not set right no packets would
> be
> > >> processed. I've never touched the gateway
> > setting.
> > >> Could that be why Static IP mode is not
> > functioning?
> > >>
> > >> Is there a sample Static IP program I can try?
> I
> > >> can't
> > >> seem to find one. The one example, static.c, is
> > for
> > >> a
> > >> web server.
> > >>
> > >> Steve
> > >>
> > >>
> > >> ________________________________
> > >>
> > >> > .
> > >>
> > >
> > >
> > >
> > >
> > > > .
>




I don’t use the pd_havelink during initialization either. I monitor what sock_init returns and if I get a 0, I assume the link was made.

When you get to the point of running your program again, break it just before the sock_init call and then step it over just sock_init. If you don’t have a valid link after the call returns then something, as far network configuration, before the call is giving you grief. Besides the TCPCONFIG define and USE_DHCP define the only network thing you do prior to the sock_init call is ifconfig?

 

From: Steve Trigero [mailto:s...@yahoo.com]
Sent: Tuesday, February 01, 2005 4:32 PM
To: r...@yahoogroups.com
Subject: RE: [rabbit-semi] Using Static IP mode

 

I'm sorry, I missed your question. The answer is yes,
I only call sock_init() once.

I have one call to ifconfig() before sock_init() and
one call to ifconfig() after sock_init().

The second ifconfig call is not executed until
pd_havelink() returns true, indicating the Rabbit is
connected to a network. This works fine for DHCP. But
pd_havelink() never returns true when in static IP
mode. So I'm in the process of re-writing my ethernet
initialization procedure to remove the pd_havelink
call when in Static IP mode. I'd don't know if that
will make a difference, but its the only think I can
see that is different between the two modes.

Steve --- Bob Hohentanner <b...@acromag.com> wrote:

> Steve,

>     Did you get my question about where you have
> your sock_init relative
> to the ifconfig calls? You only call sock_init once
> right?

> ________________________________
>
> From: Steve Trigero [mailto:s...@yahoo.com]
> Sent: Tuesday, February 01, 2005 4:16 PM
> To: r...@yahoogroups.com
> Subject: Re: [rabbit-semi] Using Static IP mode

>
> Changing the address caused pingme to work.
>
> But that doesn't explain why I can't ping my own
> program when in Static IP mode. DHCP works fine.
>
> Steve
>
>
> --- Arlen Fletcher <a...@direcway.com> wrote:
>
> > Change the IP address on your PC to 10.10.6.1 and
> > set the netmask to
> > 255.255.255.0.
> > Reboot the PC.  Try the pingme program again and
> let
> > us know the
> > results.
> >
> > Arlen
> >
> > On Feb 1, 2005, at 11:05 AM, Steve Trigero wrote:
> >
> > >
> > > I tried sample program pingme.c and it works,
> sort
> > of.
> > > At least the link light on the hub lights up. I
> > tried
> > > pinging it but I get error message "Destination
> > > unreachable". I suspect it has to do with the
> > default
> > > IP address used, 10.10.6.100. My PC is still at
> > > 192.168.100.2.
> > >
> > > I notice that pingme.c does not call ifconfig().
> > It
> > > just calls sock_init() and tcp_tick(). Or is
> there
> > > some code buried in one of the DC libraries that
> > does
> > > this?
> > >
> > > Steve
> > >
> > > --- Bob Hohentanner <b...@acromag.com>
> > wrote:
> > >
> > >> Gateway is not needed if it's just your PC and
> > the
> > >> Rabbit connected to
> > >> the hub.
> > >>
> > >> Yes, the sample static.c is for a web server,
> but
> > >> uses a static address
> > >> and you can use this sample to see if it's your
> > >> hardware or firmware
> > >> that flakey
> > >>
> > >> ________________________________
> > >>
> > >> From: Steve Trigero
> [mailto:s...@yahoo.com]
> > >> Sent: Tuesday, February 01, 2005 1:24 PM
> > >> To: r...@yahoogroups.com
> > >> Subject: RE: [rabbit-semi] Using Static IP mode
> > >>
> > >> My IT guys are asking about the gateway setting
> > in
> > >> the
> > >> Rabbit. They seem to think that this is very
> > >> important
> > >> and that if its not set right no packets would
> be
> > >> processed. I've never touched the gateway
> > setting.
> > >> Could that be why Static IP mode is not
> > functioning?
> > >>
> > >> Is there a sample Static IP program I can try?
> I
> > >> can't
> > >> seem to find one. The one example, static.c, is
> > for
> > >> a
> > >> web server.
> > >>
> > >> Steve
> > >>
> > >>
> > >> ________________________________
> > >>
> > >> > .
> > >>
> > >
> > >
> > >
> > >
> > > > .
>




Ok, so I re-wrote the initialization for Static IP. It
follows Scott's sample he sent me in an earlier post.
But, it hangs forever waiting for the ethernet to come
up. And the rabbit is plugged into a hub, not that
that should matter.

Is anything wrong with this? FYI, I'm using DC 9.10 on
a RCM3000.

int InitStaticIP()
{
int status;

sock_init();

status = ifconfig( IF_ETH0,
IFS_DHCP, 0,
IFS_IPADDR, static_ip_adrs,
IFS_NETMASK, net_mask,
IFS_END );

if ( gateway_ip_adrs )
ifconfig( IF_ETH0, IFS_ROUTER_SET,
gateway_ip_adrs, IFS_END );

if ( *domain_name == NUL )
setdomainname( NULL );
else
setdomainname( domain_name );
RdHostName( tstr );
sethostname( tstr );

ifconfig( IF_ETH0, IFS_UP, IFS_END );

while ( ifpending( IF_ETH0 ) & 1 ) {
tcp_tick(NULL);
}
return( status );
} Steve


At 03:18 PM 2/1/2005, you wrote:
>Scott,
>
>In your sample program, if the Rabbit is not connected
>to a network what happens when the Rabbit gets to
>"while (ifpending(IF_ETH0)&1)"? Does it hang there
>until a cable is plugged in?
>
>Steve

It should time out. It only waits there if DHCP is enabled and it is
searching for a server response.

In my sample the order is significant. I use #define TCPCONFIG 6, this is
the one that is defined for run-time config.

Did you try a define of NET_VERBOSE?

Also add a printf() to your code to display the ip address when it comes up.

char addr[20];
printf("IP address is: %s\n", inet_ntoa( addr, gethostid()));

<Scott ------
| Scott G. Henion| shenion@shen... |
| Consultant | Stone Mountain, GA |
| SHDesigns | PGP Key 0xE98DDC48 |
| http://www.shdesigns.org |
------
today's fortune
Do not believe in miracles -- rely on them.


At 04:46 PM 2/1/2005, you wrote:

>Ok, so I re-wrote the initialization for Static IP. It
>follows Scott's sample he sent me in an earlier post.
>But, it hangs forever waiting for the ethernet to come
>up. And the rabbit is plugged into a hub, not that
>that should matter.
>
>Is anything wrong with this? FYI, I'm using DC 9.10 on
>a RCM3000.
>
>int InitStaticIP()
>{
> int status;
>
> sock_init();
>
> status = ifconfig( IF_ETH0,
> IFS_DHCP, 0,
> IFS_IPADDR, static_ip_adrs,
> IFS_NETMASK, net_mask,
> IFS_END );

Again, what is TCPCONFIG set to? It should be 6 if you want to configure
manually. Otherwise it will likely override whatever you do. It sounds like
you have it a 0 because.

<Scott>

------
| Scott G. Henion| shenion@shen... |
| Consultant | Stone Mountain, GA |
| SHDesigns | PGP Key 0xE98DDC48 |
| http://www.shdesigns.org |
------
today's fortune
Indeed, the first noble truth of Buddhism, usually translated as
`all life is suffering,' is more accurately rendered `life is filled
with a sense of pervasive unsatisfactoriness.'
-- M.D. Epstein


Scott,

 

    He sets TCPCONFIG to 0 which according to the tcp_config.lib, expects all configuration at runtime. It shouldn’t be giving him problems unless that part of things has changed since my 7.33.

 

From: Scott Henion [mailto:s...@shdesigns.org]
Sent: Tuesday, February 01, 2005 5:05 PM
To: r...@yahoogroups.com
Subject: RE: [rabbit-semi] Using Static IP mode

 

At 04:46 PM 2/1/2005, you wrote:

>Ok, so I re-wrote the initialization for Static IP. It
>follows Scott's sample he sent me in an earlier post.
>But, it hangs forever waiting for the ethernet to come
>up. And the rabbit is plugged into a hub, not that
>that should matter.
>
>Is anything wrong with this? FYI, I'm using DC 9.10 on
>a RCM3000.
>
>int InitStaticIP()
>{
>   int status;
>
>   sock_init();
>
>   status = ifconfig(  IF_ETH0,
>                       IFS_DHCP,    0,
>                       IFS_IPADDR,  static_ip_adrs,
>                       IFS_NETMASK, net_mask,
>                       IFS_END );

Again, what is TCPCONFIG set to? It should be 6 if you want to configure
manually. Otherwise it will likely override whatever you do. It sounds like
you have it a 0 because.

<Scott>

------
| Scott G. Henion| s...@shdesigns.org |
|   Consultant   |   Stone Mountain, GA  |
|   SHDesigns    |   PGP Key 0xE98DDC48  |
|     http://www.shdesigns.org           |
------
today's fortune
Indeed, the first noble truth of Buddhism, usually translated as
`all life is suffering,' is more accurately rendered `life is filled
with a sense of pervasive unsatisfactoriness.'
                 -- M.D. Epstein




You should probably post your entire prog Steve. At least everything before
the first function also.

Steve Trigero wrote:
> Ok, so I re-wrote the initialization for Static IP. It follows
> Scott's sample he sent me in an earlier post.
> But, it hangs forever waiting for the ethernet to come up. And the
> rabbit is plugged into a hub, not that that should matter.
>
> Is anything wrong with this? FYI, I'm using DC 9.10 on a RCM3000.
>
> int InitStaticIP()
> {
> int status;
>
> sock_init();
>
> status = ifconfig( IF_ETH0,
> IFS_DHCP, 0,
> IFS_IPADDR, static_ip_adrs,
> IFS_NETMASK, net_mask,
> IFS_END );
>
> if ( gateway_ip_adrs )
> ifconfig( IF_ETH0, IFS_ROUTER_SET,
> gateway_ip_adrs, IFS_END );
>
> if ( *domain_name == NUL )
> setdomainname( NULL );
> else
> setdomainname( domain_name );
> RdHostName( tstr );
> sethostname( tstr );
>
> ifconfig( IF_ETH0, IFS_UP, IFS_END );
>
> while ( ifpending( IF_ETH0 ) & 1 ) {
> tcp_tick(NULL);
> }
> return( status );
> } > Steve >
>
> Yahoo! Groups Links >




At 05:04 PM 2/1/2005, you wrote:
Scott,
 
    He sets TCPCONFIG to 0 which according to the tcp_config.lib, expects all configuration at runtime. It shouldnt be giving him problems unless that part of things has changed since my 7.33.
 

Not true:

   TCPCONFIG | Ethernet | PPP | DHCP | Runtime | Comments
   ----------+----------+-----+------+---------+-----------
       1     |   Yes    | No  | No   |   No    |
   ----------+----------+-----+------+---------+-----------
       2     |   No     | Yes | No   |   No    |
   ----------+----------+-----+------+---------+-----------
       3     |   Yes    | No  | Yes  |   No    |
   ----------+----------+-----+------+---------+-----------
       4     |   Yes    | Yes | No   |   No    |
   ----------+----------+-----+------+---------+-----------
       5     |   Yes    | No  | Yes  |   No    | Like #3, but no optional flags
   ----------+----------+-----+------+---------+-----------
       6     |   Yes    | No  | No   |   Yes   |
   ----------+----------+-----+------+---------+-----------
       7     |   Yes    | No  | Yes  |   No    | DHCP, with static IP fallback
   ----------+----------+-----+------+---------+----------

6 is runtime config.

0 is _compile time_ config. Everything must be configured with the #define statements. This emulates the older compiler method.

<Scott>

------
| Scott G. Henion| s...@shdesigns.org |
|   Consultant   |   Stone Mountain, GA  |
|   SHDesigns    |   PGP Key 0xE98DDC48  |
|     http://www.shdesigns.org            |
------
today's fortune
Indeed, the first noble truth of Buddhism, usually translated as
`all life is suffering,' is more accurately rendered `life is filled
with a sense of pervasive unsatisfactoriness.'
                 -- M.D. Epstein


TCPCONFIG is set to 0 per Z-World. Here is a cut &
paste from their example:

#define TCPCONFIG 0 // Zero means do not do any
configuration: expects
// all config items to be
defined in the main
// program. Steve --- Scott Henion <shenion@shen...> wrote:

> At 04:46 PM 2/1/2005, you wrote:
>
> >Ok, so I re-wrote the initialization for Static IP.
> It
> >follows Scott's sample he sent me in an earlier
> post.
> >But, it hangs forever waiting for the ethernet to
> come
> >up. And the rabbit is plugged into a hub, not that
> >that should matter.
> >
> >Is anything wrong with this? FYI, I'm using DC 9.10
> on
> >a RCM3000.
> >
> >int InitStaticIP()
> >{
> > int status;
> >
> > sock_init();
> >
> > status = ifconfig( IF_ETH0,
> > IFS_DHCP, 0,
> > IFS_IPADDR, static_ip_adrs,
> > IFS_NETMASK, net_mask,
> > IFS_END );
>
> Again, what is TCPCONFIG set to? It should be 6 if
> you want to configure
> manually. Otherwise it will likely override whatever
> you do. It sounds like
> you have it a 0 because.
>
> <Scott>
>
> ------
> | Scott G. Henion| shenion@shen... |
> | Consultant | Stone Mountain, GA |
> | SHDesigns | PGP Key 0xE98DDC48 |
> | http://www.shdesigns.org |
> ------
> today's fortune
> Indeed, the first noble truth of Buddhism, usually
> translated as
> `all life is suffering,' is more accurately rendered
> `life is filled
> with a sense of pervasive unsatisfactoriness.'
> -- M.D. Epstein




I've been using TCPCONFIG of 6 for a long time (and doing runtime config.)
Give it a shot.

Steve Trigero wrote:
> TCPCONFIG is set to 0 per Z-World. Here is a cut & paste from their
> example:
>
> #define TCPCONFIG 0 // Zero means do not do any
> configuration: expects
> // all config items to be defined in the main
>
// program.
>
>
> Steve > --- Scott Henion <shenion@shen...> wrote:
>
>> At 04:46 PM 2/1/2005, you wrote:
>>
>>> Ok, so I re-wrote the initialization for Static IP. It
>>> follows Scott's sample he sent me in an earlier post.
>>> But, it hangs forever waiting for the ethernet to come
>>> up. And the rabbit is plugged into a hub, not that that should
>>> matter.
>>>
>>> Is anything wrong with this? FYI, I'm using DC 9.10 on
>>> a RCM3000.
>>>
>>> int InitStaticIP()
>>> {
>>> int status;
>>>
>>> sock_init();
>>>
>>> status = ifconfig( IF_ETH0,
>>> IFS_DHCP, 0,
>>> IFS_IPADDR, static_ip_adrs,
>>> IFS_NETMASK, net_mask,
>>> IFS_END );
>>
>> Again, what is TCPCONFIG set to? It should be 6 if you want to
>> configure manually. Otherwise it will likely override whatever you
>> do. It sounds like you have it a 0 because.
>>





Memfault State of IoT Report