[En-Nut-Discussion] RE: Reading & Writing to an external EEPROM viaTCP/IP
Alexander Baranov
Baranov at intech21.com
Mon Dec 8 15:45:27 CET 2003
I do it using external RAMTRON memory mounted on separate board and ,
connected with Ethernut through i2c interface.
----- Original Message -----
From: "Berns J. Buenaobra" <bbuenaobra at nip.upd.edu.ph>
To: <en-nut-discussion at egnite.de>
Sent: Tuesday, December 09, 2003 1:18 AM
Subject: [En-Nut-Discussion] RE: Reading & Writing to an external EEPROM
viaTCP/IP
>
> Hello:
>
> What can be the best approach here? I need to be able to write datalogs
> with contents of a persons name, time in/out and date on external EEPROM
> outside Ethernut from and to a remote PC via TCP/IP. Some suggestion and
> help for this newbee would be appreciated.
>
> Thanks.
>
>
>
> -----Original Message-----
> From: en-nut-discussion-bounces at egnite.de
> [mailto:en-nut-discussion-bounces at egnite.de] On Behalf Of
> en-nut-discussion-request at egnite.de
> Sent: Friday, December 05, 2003 6:03 AM
> To: en-nut-discussion at egnite.de
> Subject: En-Nut-Discussion Digest, Vol 2, Issue 5
>
> Send En-Nut-Discussion mailing list submissions to
> en-nut-discussion at egnite.de
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion
> or, via email, send a message with subject or body 'help' to
> en-nut-discussion-request at egnite.de
>
> You can reach the person managing the list at
> en-nut-discussion-owner at egnite.de
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of En-Nut-Discussion digest..."
>
>
> Today's Topics:
>
> 1. Re: NutThreadSetPriority (Harald Kipp)
> 2. Betr.: Re: [En-Nut-Discussion] NutThreadSetPriority (Yuri Staal)
> 3. Re: NutThreadSetPriority (Yuri Staal)
> 4. AW: [En-Nut-Discussion] NutThreadSetPriority (Oliver Schulz)
> 5. Re: AW: [En-Nut-Discussion] NutThreadSetPriority (Yuri Staal)
> 6. Re: AW: [En-Nut-Discussion] NutThreadSetPriority (Yuri Staal)
> 7. AW: AW: [En-Nut-Discussion] NutThreadSetPriority (Oliver Schulz)
> 8. Re: AW: AW: [En-Nut-Discussion] NutThreadSetPriority (Yuri Staal)
> 9. Re: AW: [En-Nut-Discussion] NutThreadSetPriority (Harald Kipp)
> 10. Re: AW: [En-Nut-Discussion] NutThreadSetPriority (Yuri Staal)
> 11. AW: AW: [En-Nut-Discussion] NutThreadSetPriority (Oliver Schulz)
> 12. Re: AW: AW: [En-Nut-Discussion] NutThreadSetPriority (Yuri Staal)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 04 Dec 2003 20:58:19 +0100
> From: Harald Kipp <harald.kipp at egnite.de>
> Subject: Re: [En-Nut-Discussion] NutThreadSetPriority
> To: "Ethernut User Chat (English)" <en-nut-discussion at egnite.de>
> Message-ID: <5.1.1.6.0.20031204205017.01b49fa0 at egnite.de>
> Content-Type: text/plain; charset="us-ascii"; format=flowed
>
> Hi Yuri,
>
> Threads do not inherit the parent's priority, but are all
> started with priority 64.
>
> When starting with your own apps, make sure to use the
> Makefile similar to those used in other Nut/OS samples.
>
> You can also check NutThreadCreate's return value. If it's
> NULL, then the system ran out of memory most probably.
>
> Finally make sure, that your threads are not blocking
> the CPU. Nut/OS is non-preemptive.
>
> Harald
>
>
>
> ------------------------------
>
> Message: 2
> Date: Fri, 05 Dec 2003 09:36:36 +0100
> From: "Yuri Staal" <staal.ya at stu.hsbrabant.nl>
> Subject: Betr.: Re: [En-Nut-Discussion] NutThreadSetPriority
> To: <en-nut-discussion at egnite.de>
> Message-ID: <sfd051bc.072 at CLHSLDZ4.hsbrabant.nl>
> Content-Type: text/plain; charset=US-ASCII
>
> Harald,
>
> i understand the fact that all thread are started with priority 64. But
> the problem is when i dont set the priority of the 4 server threads,
> only two get started, instead of the 4 i want. And thus killing my
> application.
> The only problem i can see for now, is that the system ran out of
> memory.
> I'll rewrite my complete structure, to make sure nothing else is
> incorrect.
>
> Yuri
>
>
> ------------------------------
>
> Message: 3
> Date: Fri, 05 Dec 2003 12:13:51 +0100
> From: "Yuri Staal" <staal.ya at stu.hsbrabant.nl>
> Subject: Re: [En-Nut-Discussion] NutThreadSetPriority
> To: <en-nut-discussion at egnite.de>
> Message-ID: <sfd07698.077 at CLHSLDZ4.hsbrabant.nl>
> Content-Type: text/plain; charset=US-ASCII
>
> i am now outputting almost everything that is done to HYperTerminal.
> i have seen a lot of stuff that isnt supposed to happen the way i think
> it should happen.
> for instance:
>
> for (i = 0; i < 4; i++) {
> char *thname = "main";
> thname[4] = '0' + i;
> NutThreadCreate(thname, NutMain, (void *) (u_short) i, 640);
> printf("[%i] Name: %s\r\n", i, tdp->td_name);
> }
> NutThreadSetPriority(255);
> printf("[%i] Idle Thread Priority: %u\r\n", i, tdp->td_priority);
>
> This is the way im creating my 4 threads. setting the priority happens
> "outside" the loop. Which is done because it is stated this way in the
> docs.
> After viewing the output, all 4 threads are created, but it doesnt get
> to the part where the priority is lowered.
>
> If i set the priority "inside" the loop, it gets set. 4 times
> offcourse...
> from one hand, its pretty obvious why this happens. the thread gets a
> low priority and Nut/OS switches to the high priority main thread.
> maybe im just being ignorant, but i dont understand what effect
> NutThreadYield() has in an endless for loop. Because when the priority
> gets set so low, the thread loses control over itself, thus, the way i
> see it, isnt capable of forfilling his task by Yielding the thread...
> maybe somebody can explain this a bit more.
>
> i have also put a printf in the endless for loop, and when i declare the
> priority inside the for loop, it spams alot onto the console.
> i output the state the thread is in at that moment. After a while (and
> this has been always around 1 minute) the spamming stops, and the system
> locks up.
> Could this have something to do with the NutThreadYield() and setting
> the priority in the wrong way?
>
> my questions have grown out to a long story, and i hope nobody minds
> reading it :-)
>
> Regards,
> Yuri
>
>
> ------------------------------
>
> Message: 4
> Date: Fri, 5 Dec 2003 13:00:16 +0100
> From: "Oliver Schulz" <Oliver.Schulz at bong.de>
> Subject: AW: [En-Nut-Discussion] NutThreadSetPriority
> To: "Ethernut User Chat (English)" <en-nut-discussion at egnite.de>
> Message-ID:
> <E7D3411F45AA0F4A913D3F0CE266F95C0E2B03 at uwp-ex001.bong.local>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hi Yuri,
>
> lets start to examine your code and answer your questions...
>
> >
> > for (i = 0; i < 4; i++) {
> > char *thname = "main";
> > thname[4] = '0' + i;
> > NutThreadCreate(thname, NutMain, (void *) (u_short) i, 640);
> > printf("[%i] Name: %s\r\n", i, tdp->td_name);
> > }
> > NutThreadSetPriority(255);
> > printf("[%i] Idle Thread Priority: %u\r\n", i, tdp->td_priority);
>
> 1. If you set the thread number with "thname[4] = '0' + i;" you
> overwrite the string termination character! thname is prior set to
> "main", so it has 4 characters [0..3] and one termination char [4]. If
> you set thname to "main0" for example, the termination char is on index
> [5] and will not be overwritten.
>
> 2. You MUST assign the return value from NutThreadCreat to tdp! You
> don't, so tdp points somewhere into nirvana.. Please use "tdp =
> (NUTTHREADINFO*) NutThreadCreate (...);"
>
> 3. If you try to print the idle thread priority, tdp points still to the
> last created thread. This will not work. Use
> "runningThread->td_priority" instead. But note, calling
> NutThreadSetPrio(255) will immediately suspend your idle thread and it
> executes printf first after it becomes active again..
>
> > maybe im just being ignorant, but i dont understand what effect
> > NutThreadYield() has in an endless for loop. Because when the priority
> > gets set so low, the thread loses control over itself, thus, the way i
> > see it, isnt capable of forfilling his task by Yielding the thread...
> > maybe somebody can explain this a bit more.
>
> If all other threads are waiting for something (in most cases for timers
> or other events) the idle thread becomes active. Just imagine that all
> your "worker"-threads are waiting for a tcp connection...
> If than the idle thread does not call NutThreadYield(), it will never
> suspended and all other thread have no chance ever to get to run.
>
>
> Hope that helps,
> Oliver.
>
>
> ------------------------------
>
> Message: 5
> Date: Fri, 05 Dec 2003 13:13:01 +0100
> From: "Yuri Staal" <staal.ya at stu.hsbrabant.nl>
> Subject: Re: AW: [En-Nut-Discussion] NutThreadSetPriority
> To: <en-nut-discussion at egnite.de>
> Message-ID: <sfd0847a.051 at CLHSLDZ4.hsbrabant.nl>
> Content-Type: text/plain; charset=US-ASCII
>
> Oliver,
>
> your first point is the one that struck me first, but like i said, this
> is how it is stated in the example...thats why i started doing it that
> way.
>
> your second point. My bad for not pasting all the code. This is what i
> use:
> NUTTHREADINFO *tdp = nutThreadList;
>
> point 3 again, is a very valid point. THe reason i printed the info, was
> to see if the loop completed itself.
>
> Thanks alot for your reply, i think it will be usefull :-)
>
> Yuri
>
>
>
> ------------------------------
>
> Message: 6
> Date: Fri, 05 Dec 2003 13:41:51 +0100
> From: "Yuri Staal" <staal.ya at stu.hsbrabant.nl>
> Subject: Re: AW: [En-Nut-Discussion] NutThreadSetPriority
> To: <en-nut-discussion at egnite.de>
> Message-ID: <sfd08b42.041 at CLHSLDZ4.hsbrabant.nl>
> Content-Type: text/plain; charset=US-ASCII
>
> Ok, this doesnt really have to do anything with setting priorities...
> but i just wanted to ask.
>
> im checking what threads are running, with what priorities etc, and i
> see this:
>
> 1FFD arpex 64 SLP 0000 0D7C 1FD7 346 OK
> 1C76 httpd4 64 SLP 233E 0000 1C4C 598 OK
> 19D9 httpd3 64 SLP 253C 0000 19AF 598 OK
> 173C tcpsm 64 RDY 0450 0000 1714 472 OK
> 151F rxi5 9 RDY 0450 0CB6 14F9 602 OK
> 1282 httpd2 64 RUN 0450 0000 1258 598 OK
> 0C85 rxi5 9 SLP 057B 0CB6 0C5F 602 OK
> 09E8 httpd1 64 SLP 1CF9 0000 09BE 598 OK
> 073E idle 254 RDY 0450 0000 0718 346 OK
>
> as you may see, there are 4 httpd threads. but there are also TWO rxi5
> threads...
> for as much as i know, the rxi5 thread is the ethernet receive thread...
> shouldnt there be 1 rxi5 and 1 txi5 thread, instead of 2 rxi5 threads?
> :-|
> its kind of mind boggling :-)
>
> Yuri
>
>
>
> ------------------------------
>
> Message: 7
> Date: Fri, 5 Dec 2003 13:55:11 +0100
> From: "Oliver Schulz" <Oliver.Schulz at bong.de>
> Subject: AW: AW: [En-Nut-Discussion] NutThreadSetPriority
> To: "Ethernut User Chat (English)" <en-nut-discussion at egnite.de>
> Message-ID:
> <E7D3411F45AA0F4A913D3F0CE266F95C312E10 at uwp-ex001.bong.local>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hi Yuri,
>
> > your first point is the one that struck me first, but like i
> > said, this
> > is how it is stated in the example...thats why i started doing it that
> > way.
> Sometimes even examples are wrong. Which example did use actually use?
> httpd?
>
> >
> > your second point. My bad for not pasting all the code. This is what i
> > use:
> > NUTTHREADINFO *tdp = nutThreadList;
> Do you use this line inside the loop or outside?
>
>
>
> ------------------------------
>
> Message: 8
> Date: Fri, 05 Dec 2003 14:01:50 +0100
> From: "Yuri Staal" <staal.ya at stu.hsbrabant.nl>
> Subject: Re: AW: AW: [En-Nut-Discussion] NutThreadSetPriority
> To: <en-nut-discussion at egnite.de>
> Message-ID: <sfd08fdd.005 at CLHSLDZ4.hsbrabant.nl>
> Content-Type: text/plain; charset=US-ASCII
>
> >Sometimes even examples are wrong. Which example did use actually use?
> httpd?
> Yes, i used the httpd example as a reference point
>
> >Do you use this line inside the loop or outside?
> outside the loop, inside the idle thread...
> but this isnt the reason why my application crashes, cause it crashed
> even before it used that :-)
>
> Yuri
>
>
> ------------------------------
>
> Message: 9
> Date: Fri, 05 Dec 2003 14:10:01 +0100
> From: Harald Kipp <harald.kipp at egnite.de>
> Subject: Re: AW: [En-Nut-Discussion] NutThreadSetPriority
> To: "Ethernut User Chat (English)" <en-nut-discussion at egnite.de>
> Message-ID: <5.1.1.6.0.20031205134920.02efa7e0 at egnite.de>
> Content-Type: text/plain; charset="us-ascii"; format=flowed
>
> Yuri,
>
> from your posts I may conclude, that you are not too
> experienced with C. This is fine. Programming embedded
> devices without memory protection requires some extra
> care, but even newbies can do it...at least with some
> help.
>
> However, I'd recommend to start with very simple and
> small programs first. Modifying larger code samples
> without understanding what is done inside, bears the
> risk of side effects, which are difficult to find
> and it's also most difficult to help you in such cases.
>
> Please understand, that I get highly alarmed when you
> post a thread list with two rxi5 threads running.
> But I'm unable to calm down without any chance to
> reconstruct the problem. Don't get me wrong, please.
> Many bugs were detected by beginners, because they
> try uncommon ways to implement function. But bug
> reports like "I made a few changes on a large program
> and now it crashes" doesn't help.
>
> If you think you detected a problem, best write a
> most simple sample to demonstrate it. You will learn
> more and we can help fast.
>
> Hope you don't take this as an unfriendly reply. It's
> just an advice and I'm old enough to give advices. :-)
>
> Harald
>
>
>
> ------------------------------
>
> Message: 10
> Date: Fri, 05 Dec 2003 14:29:58 +0100
> From: "Yuri Staal" <staal.ya at stu.hsbrabant.nl>
> Subject: Re: AW: [En-Nut-Discussion] NutThreadSetPriority
> To: <en-nut-discussion at egnite.de>
> Message-ID: <sfd09681.039 at CLHSLDZ4.hsbrabant.nl>
> Content-Type: text/plain; charset=US-ASCII
>
> Harald,
>
> you are kind of right. Im not to experienced with embedded programming.
> The problem as i see it is as follows:
>
> I started with Ethernut not really knowing too much about it.
> I read the docs, looked at the code examples, and tried to understand
> all that is happening inside. After that I decided to start working on
> my own application.
> The first thing i did was create a really simple webserver, which worked
> really nice. No problem whatsoever. After some time i discovered the
> fact that displaying multiple images isnt done the way i thought it
> would be (with the 4 threads and all)
> Like i said, i developed my application from scratch, using the docs and
> examples. Now after some time i experience (in my eyes) very strange
> things.
> Like setting the thread priority the way its said to be done in a few
> docs, doesnt work for me. This could be because my application was at
> first hand not good, but worked for some wonderfull reason.
> And it could be for some other reasons... i dont know, thats the
> problem.
> and about the two rxi5 threads, i really dont know what has happend
> there.Like i said, i found it very strange. I will try to close in on
> the problem, so I can give you an exact model of what was done, and how
> it was done.
>
> And no, i do not take your reply as an unfriendly one. I do not want to
> be bugging all you, but i "hate" problems that arise without a really
> good reason (to me that is ;-) )
>
> Yuri
>
>
>
>
>
>
> ------------------------------
>
> Message: 11
> Date: Fri, 5 Dec 2003 14:36:25 +0100
> From: "Oliver Schulz" <Oliver.Schulz at bong.de>
> Subject: AW: AW: [En-Nut-Discussion] NutThreadSetPriority
> To: "Ethernut User Chat (English)" <en-nut-discussion at egnite.de>
> Message-ID:
> <E7D3411F45AA0F4A913D3F0CE266F95C0E2B04 at uwp-ex001.bong.local>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hi Yuri,
>
> >
> > as you may see, there are 4 httpd threads. but there are also TWO rxi5
> > threads...
> > for as much as i know, the rxi5 thread is the ethernet
> > receive thread...
> > shouldnt there be 1 rxi5 and 1 txi5 thread, instead of 2 rxi5 threads?
> There should be just ONE rxi5 thread, for sure. This thread is created
> by a call to NutRegisterDevice (eth0,...);
> So be sure not to call this function twice!
>
> A transmitter thread does not exists, however if a thread sends some
> bytes to the nic, it is suspended until the transmission of the packet
> is finished.
>
> Here a code snippet from httpd:
>
> char *thname = "httpd0";
> thname[5] = '0' + i;
>
> You can see here, that the string index [5] is the char '0', not the
> termination character. If you use a shorter name like "main", you must
> supply one byte for the numbering ("main0") and of course adjust the
> index 5 to 4..
>
> If you use "NUTTHREADINFO *tdp = nutThreadList;" outside the loop, tdp
> points always to the last created thread, when this assignment is
> executed. To make it work correctly, assign the return value of
> NutThreadCreate to tdp!
>
>
> Oliver.
>
>
> ------------------------------
>
> Message: 12
> Date: Fri, 05 Dec 2003 15:02:42 +0100
> From: "Yuri Staal" <staal.ya at stu.hsbrabant.nl>
> Subject: Re: AW: AW: [En-Nut-Discussion] NutThreadSetPriority
> To: <en-nut-discussion at egnite.de>
> Message-ID: <sfd09e31.004 at CLHSLDZ4.hsbrabant.nl>
> Content-Type: text/plain; charset=US-ASCII
>
> Harald, Oliver,
>
> you can put a stamp on my forehead, and call me a supernewbie...
> after reading Olivers last reply something struck my mind. I was
> registering the devices INSIDE the main thread. which i offcourse
> *tried* to run 4 times...
> this was because i just changed the one time thread creation (which
> offcourse only *one* time registers the devices) into the 4 thread
> creation...
> rawr, i really find myself rather stupid at the moment :-p
> i almost for sure know that this HAS to be the problem, so i can fix it
> :-)
>
> Kind regards,
> Yuri Staal
>
>
> ------------------------------
>
> _______________________________________________
> En-Nut-Discussion mailing list
> En-Nut-Discussion at egnite.de
> http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion
>
>
> End of En-Nut-Discussion Digest, Vol 2, Issue 5
> ***********************************************
>
>
> _______________________________________________
> En-Nut-Discussion mailing list
> En-Nut-Discussion at egnite.de
> http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion
More information about the En-Nut-Discussion
mailing list