Author Topic: AIS226DS / MOD-SMB380 I2C evaluation on LPC2378-STK  (Read 72651 times)

Offline kb1gtt

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: AIS226DS / MOD-SMB380 I2C evaluation on LPC2378-STK
« Reply #90 on: December 31, 2010, 11:25:19 PM »
Spot on again. Thanks. I've got another one though.

I browse to http://10.10.10.3/5MulTable.htm?J1=60.254&J2=68.954 which causes fnHandleWeb to run my newly created case 'J'. Which twice calls fnWrite(INTERNAL_ROUTE, ucMessage, HEADER_LENGTH + ucLength+2); // pass the message to the destination task

Both times it runs, INTERNAL_ROUTE is 0x00 and HEADER_LENGTH + ucLength+2 is 0x000d. ucMessage looks like this the first time through.



then the the second time through



Then in my-frist-task.c I hit this line twice as expected.

while (fnRead( PortIDInternal, ucInputMessage, HEADER_LENGTH)) {
   ucLength = fnRead( PortIDInternal, ucInputMessage, ucInputMessage[MSG_CONTENT_LENGTH]);

When stopped on the ucLength line, ucInputMessage looks like this on the first pass,



then like this on the second pass.



It appears like the second pass is rolling a bit. I expect 'E' in ucInputMessage[3] not ucInputMessage[0], so it appears for some reason the second time through it rolled down by 3 places. Perhaps I have to clean up some variable or memory between passes, I don't know at this point. Is this something that might jump out? Hmmm, could HEADER_LENGTH + ucLength+2 be wrong, I tried my best to eye ball that, but I don't really know if it's completely right. It seems like on the second pass in my-first-task, it only writes 5 characters as well. I'm not seeing why the second pass isn't giving me the message I expecting.

Offline kb1gtt

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: AIS226DS / MOD-SMB380 I2C evaluation on LPC2378-STK
« Reply #91 on: January 01, 2011, 12:24:42 PM »
It appears I have fixed this. I changed case 'J' like this
Code: [Select]
ucMessage[ MSG_CONTENT_LENGTH ] = ucLength+2;
fnWrite(INTERNAL_ROUTE, ucMessage, HEADER_LENGTH + ucLength + 2); // pass the message to the destination task
Then my-first-task like this
Code: [Select]
while (fnRead( PortIDInternal, ucInputMessage, EADER_LENGTH)) {
ucLength = fnRead( PortIDInternal, ucInputMessage, cInputMessage[MSG_CONTENT_LENGTH]);
I'm not exactly sure why I need +2, instead of +1. I think it's because the example didn't need to copy the '/0', where I'm looking for that. With out it, I would read old junk data from prior usage.

Offline kb1gtt

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: AIS226DS / MOD-SMB380 I2C evaluation on LPC2378-STK
« Reply #92 on: January 09, 2011, 10:53:19 PM »
I'm have good success in creating a web page that allows me to configure embedded parameters via HTTP page. However I'm also trying to get a stream of binary data out of it. Right now myfirsttask runs about every .2 seconds producing new data on each pass. I'm looking to stream this data to a blah.csv file on my PC. In webinterface.c I can access the variables used by myfirsttask, which includes an instantaneous snap shot of the stream data at that point. However that data is only good for that instance. I need webinterface.c to wait until new data is ready, then send the data as its produced.

If the stream data is old and has already been sent, I currently return from webinterface.c with a length of 0. Then on the next pass if new data is available, I send it out via http. This seems to have nearly worked, except I'm wasting CPU cycles by polling with webinterface.c, and after I get two chunks of streamed data, txlength overflows and things go bad.

I've tried setting task E to suspended then in myfirsttask, I set it back to stop. I expected this to prevent the code in webinterface.c from running, however it keeps running. Which didn't work as I expected. So I wonder, am I using this correctly? Is there a way I can pause the http code until a new chunk of data is ready in myfirsttask? Perhaps I should be using passing messages but I couldn't figure out how to pass those from myfristtask to the function in webinterface.c.

I'm at a bit of a loss right now.

Offline kb1gtt

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: AIS226DS / MOD-SMB380 I2C evaluation on LPC2378-STK
« Reply #93 on: January 10, 2011, 11:23:05 AM »
Hmmm, Is fnInsertString a part of this task?

uTaskerStateChange(TASK_ETHERNET, UTASKER_SUSPENDED);

I seem to recall that this code can run from serial coms as well as Ethernet coms. Perhaps it's not stopping because it's not part of that task. I'm having a bit of trouble figuring out the included scope of TASK_ETHERNET.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3076
    • View Profile
    • uTasker
Re: AIS226DS / MOD-SMB380 I2C evaluation on LPC2378-STK
« Reply #94 on: January 10, 2011, 09:48:18 PM »
Hi

Take a look at SUPPORT_DELAY_WEB_SERVING. This can be used to delay responding until data is ready.
I never used it together with dynamic content insertion but I think that it is basically the soluton required in this case.

TCP and web handling are call-back functions from the Ethernet task - I wouldn't try suspending the Etheret task because it may result in lost Ethernet frames and probably won't help with delayed responses.

Regards

Mark

Offline kb1gtt

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: AIS226DS / MOD-SMB380 I2C evaluation on LPC2378-STK
« Reply #95 on: January 13, 2011, 11:02:56 AM »
Is there a way to use return DELAY_SERVING; from fnInsertString? I seem to have that function working from from fhHandleWeb, but it jumps off in the weeds when I run it from fnInsertString. I found this thread http://www.utasker.com/forum/index.php?topic=94.msg381#msg381 which helps me understand this delay web page thing, but I haven't figured out how to use it several times to get each piece of data.