gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Hermes eLIBS release 2

#120816 - SpacedCowboy - Tue Mar 06, 2007 7:16 am

Has anyone got the WiFi to work in their own programs ? I was trying to put together the simplest connect-to-the-wifi-network program by cutting down the 0WifiLoader example, but I'm running into problems figuring out just what you need to keep :-(

All I can get is a blank screen on startup. I can't see how to attach the code for main.cpp, so here's a URL to the source-code I'm using. It's pretty short :-)

On the "old" dswifi code, you had to have the arm7 running some code, and the arm9 running some code - that doesn't seem to be the case for the new dswifi lib (or maybe it's just hidden better), but the 0wifiloader example doesn't seem to have any arm7 code in it...

Anyway, if anyone can take a look and tell me what I'm doing wrong, I'd much appreciate it. I basically want wifi and threads, so this library would be perfect, if I could just get it to work...

Cheers,

Simon

#120835 - OOPMan - Tue Mar 06, 2007 12:21 pm

Why is this thread titled Hermes eLIBS release 2?

It seems to have nothing to do with Hermes' stuff and the poster certainly isn't Hermes...
_________________
"My boot, your face..." - Attributed to OOPMan, Emperor of Eroticon VI

You can find my NDS homebrew projects here...

#120847 - SpacedCowboy - Tue Mar 06, 2007 5:32 pm

Er, perhaps I'm mistaken then, or there are two Hermes, but I thought it was he who wrote eLIBS2 (the library formally known as multithread+esound), available at this site, and also mentioned in this forum

This is the library that Hermes (?) has integrated dswifi with his multithreading library - which is exactly what I want (they both used TIMER3 previously. It looks as though he's converted the dswifi library to use TIMER2).

Any help (even pointing me at the right 'Hermes' if that's the case) gratefully appreciated :-)

#120862 - Puyo - Tue Mar 06, 2007 9:30 pm

Quote:
but the 0wifiloader example doesn't seem to have any arm7 code in it...

Actually it does & nothing major changed since "old" wifi library.

You can use original wifi examples & Hermes`s stuff together too.

#120880 - SpacedCowboy - Wed Mar 07, 2007 12:23 am

Puyo wrote:

Actually it does & nothing major changed since "old" wifi library.


Ah, ok, yes there's ARM7 code in there, but in the WiFi examples for the original library, there's an arm7 directory with stuff like:
Code:

int main()
 ...
 ...
{ // sync with arm9 and init wifi
        u32 fifo_temp;   

          while(1) { // wait for magic number
        while(REG_IPC_FIFO_CR&IPC_FIFO_RECV_EMPTY) swiWaitForVBlank();
      fifo_temp=REG_IPC_FIFO_RX;
      if(fifo_temp==0x12345678) break;
        }
        while(REG_IPC_FIFO_CR&IPC_FIFO_RECV_EMPTY) swiWaitForVBlank();
        fifo_temp=REG_IPC_FIFO_RX; // give next value to wifi_init
        Wifi_Init(fifo_temp);
       
        irqSet(IRQ_FIFO_NOT_EMPTY,arm7_fifo); // set up fifo irq
        irqEnable(IRQ_FIFO_NOT_EMPTY);
        REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_RECV_IRQ;

        Wifi_SetSyncHandler(arm7_synctoarm9); // allow wifi lib to notify arm9
  } // arm7 wifi init complete
  ...
  ...


... which is the sort of thing I was looking for in Hermes' library and couldn't find. I thought it might be to do with him setting up that code in the library and using his RPC methods to do the work, but trying to factor out the "loader" part of the 0WifiLoader example to test that didn't work for me... The magic numbers (Hermes uses '2' and '4' from what I can gather) seem to have changed as well...

I'm still pretty new at this, and I'm only guessing at what the assembler code does - from your comment below, it looks as though that's nothing to do with the WiFi library (which is good to know)

Puyo wrote:
You can use original wifi examples & Hermes`s stuff together too.


Cool - I'll try that this evening :-)
[/code]

Cheers
Simon

#120907 - SpacedCowboy - Wed Mar 07, 2007 4:33 am

So, thanks to Puyo suggesting I try the existing example programs, I've got the WiFi wifi_test_lib program running with a couple of threads in the background printing to the top screen, while the WiFi 'playwardriving' goes about its business on the bottom screen :-)

Some thoughts...

My test thread-funcs look like

Code:

void threadFunc1(void *arg)
   {
   int count = 0;
   char buf[128];
   
   while (1)
      {
      sprintf(buf, "Thread 1: %d\n", count);
      printtop(buf);
      count ++;
      Sleep_Timer_Thread(25);      // 1 second
      }
   }


(ie: they don't do very much). They didn't do anything at all when they were scheduled with:

Code:

   int status = Create_Thread(THREAD_PRIORITY_NORMAL,
                        threadFunc1, NULL,
                        thrStack1, 4096*4);
   if (status == THD_ERROR)
      printtop("Error creating thread\n");
   else
      {
      char buf[128];
      sprintf(buf, "Thread created: %d\n", status);
      printtop(buf);
      }


... Once I'd changed the THREAD_PRIORITY_NORMAL to THREAD_PRIORITY_HIGH, I got both (2 identical threads) threads doing their thing. Even then, though, you'll notice that the delay in the Sleep_Timer_Thread() call is set to 25. I started off with that being 1000 (because the docs say the delay is expressed in milliseconds). I realised the scale was wrong when I just left the program running on the DS for a while (about 40 seconds) - the second pass through the loop occured, and the count=2 line was printed.

Anyway, multitasking, have WiFi, I'm happy :-)

Simon