<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<style>
<!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Times New Roman";}
h1
{margin-top:12.0pt;
margin-right:0cm;
margin-bottom:6.0pt;
margin-left:0cm;
page-break-after:avoid;
font-size:18.0pt;
font-family:Arial;}
h2
{margin-top:8.0pt;
margin-right:0cm;
margin-bottom:6.0pt;
margin-left:0cm;
page-break-after:avoid;
font-size:14.0pt;
font-family:Arial;
font-style:italic;}
h3
{margin-top:6.0pt;
margin-right:0cm;
margin-bottom:4.0pt;
margin-left:0cm;
page-break-after:avoid;
font-size:12.0pt;
font-family:"Times New Roman";}
h4
{margin-top:6.0pt;
margin-right:0cm;
margin-bottom:4.0pt;
margin-left:0cm;
page-break-after:avoid;
font-size:12.0pt;
font-family:"Times New Roman";
font-style:italic;}
h5
{margin-top:6.0pt;
margin-right:0cm;
margin-bottom:4.0pt;
margin-left:0cm;
page-break-after:avoid;
font-size:10.0pt;
font-family:Arial;}
h6
{margin-top:6.0pt;
margin-right:0cm;
margin-bottom:4.0pt;
margin-left:0cm;
page-break-after:avoid;
font-size:10.0pt;
font-family:Arial;
font-style:italic;}
p.MsoHeading7, li.MsoHeading7, div.MsoHeading7
{margin-top:4.0pt;
margin-right:0cm;
margin-bottom:3.0pt;
margin-left:0cm;
page-break-after:avoid;
font-size:10.0pt;
font-family:"Times New Roman";
font-weight:bold;}
p.MsoHeading8, li.MsoHeading8, div.MsoHeading8
{margin-top:4.0pt;
margin-right:0cm;
margin-bottom:3.0pt;
margin-left:0cm;
page-break-after:avoid;
font-size:10.0pt;
font-family:"Times New Roman";
font-weight:bold;
font-style:italic;}
p.MsoHeading9, li.MsoHeading9, div.MsoHeading9
{margin-top:4.0pt;
margin-right:0cm;
margin-bottom:3.0pt;
margin-left:0cm;
page-break-after:avoid;
font-size:10.0pt;
font-family:"Times New Roman";
font-weight:bold;
font-style:italic;}
p.MsoSignature, li.MsoSignature, div.MsoSignature
{margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Times New Roman";}
p.MsoBodyText, li.MsoBodyText, div.MsoBodyText
{margin-top:0cm;
margin-right:0cm;
margin-bottom:6.0pt;
margin-left:0cm;
font-size:10.0pt;
font-family:"Times New Roman";}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;}
p.WfxFaxNum, li.WfxFaxNum, div.WfxFaxNum
{margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Times New Roman";}
p.WfxTime, li.WfxTime, div.WfxTime
{margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Times New Roman";}
p.WfxDate, li.WfxDate, div.WfxDate
{margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Times New Roman";}
p.WfxRecipient, li.WfxRecipient, div.WfxRecipient
{margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Times New Roman";}
p.WfxCompany, li.WfxCompany, div.WfxCompany
{margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Times New Roman";}
p.WfxSubject, li.WfxSubject, div.WfxSubject
{margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Times New Roman";}
p.WfxKeyword, li.WfxKeyword, div.WfxKeyword
{margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Times New Roman";}
span.E-MailFormatvorlage26
{mso-style-type:personal-compose;
font-family:Arial;
color:windowtext;}
@page Section1
{size:595.3pt 841.9pt;
margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.Section1
{page:Section1;}
-->
</style>
</head>
<body lang=DE link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Hallo,<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>ich möchte eine Datenstruktur im EEPROM das Atmega128 auf
dem ethernut board speichern.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Dazu habe ich folgende Funktion:<o:p></o:p></span></font></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'>int
NutNetAppSaveConfig(void)<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'>{<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'> u_char *cp;<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'> u_short i;<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'><o:p> </o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'> netconf.size =
sizeof(NETWORK);<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'> strcpy(netconf.magic,
CONFAPP_NET_EE_MAGIC);<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'> for (cp =
(u_char *) & netconf, i = 0; i < sizeof(NETWORK); cp++, i++)<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'> if
(eeprom_read_byte((void *) (i + CONFAPP_NET_EE_OFFSET)) != *cp)<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'>
eeprom_write_byte((void *) (i + CONFAPP_NET_EE_OFFSET), *cp);<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'><o:p> </o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'> </span></font></i><i><font
face=Arial><span style='font-family:Arial;font-style:italic'>return 0;<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial;font-style:italic'>}<o:p></o:p></span></font></i></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Die zugehörige Funktion zum auslesen ist:<o:p></o:p></span></font></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'>int
NutNetAppLoadConfig(void)<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'>{<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'>
eeprom_read_block(&netconf, (void*) CONFAPP_NET_EE_OFFSET,
sizeof(NETWORK));<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'> if
(netconf.size != sizeof(NETWORK) || strcmp(netconf.magic, CONFAPP_NET_EE_MAGIC)
!= 0) {<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'> memset(&netconf,
0, sizeof(netconf));<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'> strcpy(netconf.hostname,
"solarnut");<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'> memset(&netconf.dns1,
0, sizeof(netconf.dns1));<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'> memset(&netconf.dns2,
0, sizeof(netconf.dns2));<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'> </span></font></i><i><font
face=Arial><span style='font-family:Arial;font-style:italic'>return -1;<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial;font-style:italic'> }<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial;font-style:italic'> return 0;<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial;font-style:italic'>}</span></font></i><font face=Arial><span
style='font-family:Arial'><o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Die Struktur ist folgendermaßen beschaffen:<o:p></o:p></span></font></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'>typedef struct
_NETWORK NETWORK;<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'>struct _NETWORK {<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'> u_char
size;<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'> u_char
magic[6];<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'> <o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'> u_char
dhcp;<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'> u_char
hostname[MAXLEN_NAMES];<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'> u_long
dns1;<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'> u_long
dns2;<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial;font-style:italic'>};<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial;font-style:italic'>extern NETWORK netconf;<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial;font-style:italic'><o:p> </o:p></span></font></i></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>die verwendeten konstanten sind folgendermaßen definiert:<o:p></o:p></span></font></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'>#define
CONFAPP_NET_EE_OFFSET 100<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'>#define
CONFAPP_NET_EE_MAGIC "APPNET"<o:p></o:p></span></font></i></p>
<p class=MsoNormal><i><font size=2 face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;font-style:italic'><o:p> </o:p></span></font></i></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Die Struktur wird also fast direkt nach der CONFNET Struktur
mit den restlichen ip einstellungen geschrieben.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Die nächste Struktur ab offset 132 (Wie groß sind eigentlich
die u_long variablen – sind doch 4byte?)<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Das Problem ist jetzt, dass nur die variable dhcp nicht
richtig geschrieben wird (erlaubte werte sind 0 und 1). D.h. nach dem Schreiben
ist die variable netconf.dhcp wieder = 0, auch wenn sie vorher = 1 war…<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Das seltsame ist: Alle anderen Werte werden richtig
geschrieben!<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Mich verwundert diese Tatsache etwas – soll heißen ich
bin momentan ratlos und bitte um hilfe…<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Ach so: Beim speichern der Strukturen wird zuerst
NutNetSaveConfig() und dann NutNetAppSaveConfig() (obige funktion) aufgerufen…
vielleicht ist das relevant?<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Thx<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Martin<o:p></o:p></span></font></p>
</div>
</body>
</html>