Jump to content

dswifilib without libnds?


ttursas

Recommended Posts

If I read my debug output correctly the ARM9 side doesn't fail sending the UDP packet (added some debug stuff to sendto()).

But what happens next? I changed the ARM7 side of my program to your wifi_example1's ARM7 side (plus libnds7), but

no help there. If I change the ARM9 init to that init in the example my app just gets stuck with a black screen... For some

reason I cannot use my 3D stuff with libnds9. Might be the libnds's interrupt handling, don't know yet, but got to find out.

 

It was too hot in Turkey (the worst day was +48C) for serious dev'ing, and we were busy getting cheated all the time by the

locals (the Turkish sense of humor, or greed, I guess, never going back anyway). But I found out that if I compiled the same

sources under Windows, I could always send one UDP packet from NDS to Windows, and then the NDS game got frozen.

Weird. Same DevKitARM but different result.

 

Next I'll check malloc() and free(), and do other testing (like add some debugging stuff to dswifi)...

I did some testing and couldn't make malloc() and free() to break (lots of malloc()s, free()s, and memory writes and reads, and

verified that there was no data corruption). Also my own memory manager passed the tests...

Link to comment
Share on other sites

I copied my network code (connectionless UDP sendto) to wifi_example1, but it doesn't work much better: I can send exactly

12 UDP packets (2 byte payloads each), and after that nothing comes through. After I restart wifi_example1 I can again send

those 12 UDP packets... And this is with the latest sources, and just adding that UDP code to your wifi_example1.

 

Augh...

 

Tried both my old blue DS and the new white DS lite, but the result was the same. And TCP doesn't connect to my Linux machine

at all. I have opened the ports I use in my router, and that shouldn't be the reason. When I look at the lights on the router I can

see that the DS doesn't send anything after those 12 UDP packets that reach my server program.

 

Any ideas? It's weird because in wifi_example1 you make a TCP connection to www.akkit.org and read and display some data,

and it works perfectly fine (looped the thing 20 times in a row a couple of times). I don't think it's my UDP code, because it works

100% on my Linux machine, and the UDP client code is just a couple of lines.

 

Sometimes the client doesn't start giving errors and succeeds sending lots of UDP packets, but none of them come through.

The router lights blink, and looks like it is recieving the data, but nothing comes through to my server. I guess the packets

might be broken somehow, and the router just drops them, as it's very quiet on my ADSL modem side.

 

Anyway, because www.akkit.org works fine there might be a problem with dswifilib and my local configuration? I have a DI-524

wireless router connected to my ADSL modem, and my Linux box is also connected to that ADSL box. What could cause

such behaviour? I wish I had a remote UDP server machine so I could do testing outside the local loop, but no... :( Mario Kart

works just fine, but how come I can send just 12 UDP packets to my local server, and after that sendto() gives -1?

Edited by ttursas
Link to comment
Share on other sites

Also plugged my Linux box to the D-Link DI-524 wireless router directly, so that both DS and the PC were under the same

local network. Fiddled with the port settings in D-Link, and used the PC's IP address directly when sending the UDP packets

instead of its human readable name, but still got the same behaviour. 12 packets go through, after that sendto() gives -1.

 

Am I sending the packets too fast (one 2 byte packet every second frame)? Could my 64bit Athlon X2 4400+ be the culprit (i.e.,

DevKitARM has fully been tested with it)? Argh, anything?

Link to comment
Share on other sites

  • 3 weeks later...

Just tested dswifilib 0.3b, but it doesn't seem to solve my problem. I managed to send one UDP packet to my

server and my game would freeze. :)

 

Also tried TetattDS, and plugged 0.3b into it, but it couldn't connect to the server either I had running in my local loop.

 

Any ideas? I'll continue my investigations with 0.3b...

Link to comment
Share on other sites

Got TetattDS to work with 0.3b! I guess this is a problem with my D-Link DI-524 as I plugged both my PC and DS into it

(DS via wifi, ofcourse), and addressed my PC directly using its IP, and the game works. If my PC is outside DI-524, then it

doesn't work. Also wifi_example1 works perfectly with my UDP code plugged into it, if PC and DS are both in 192.168.0.*

under DI-524. With 0.3a this didn't work either.

 

Now back to my own game, it sends one UDP and the PC recieves it, and at the very same moment the PC recieves the

UDP packet my DS freezes. sendto() on the DS returns 1 (one byte payload there), so the freezing comes later. Perhaps

the interrupts get fuxored?

 

More investigations needed... :) But looks pretty good so far...

Link to comment
Share on other sites

Seems that on the ARM9 side when it gets an IPC_FIFO_NOT_EMPTY interrupt (after sending that one UDP packet

to my PC server), and calls Wifi_Sync() in the interrupt handler, the game just freezes. What can happen in Wifi_Sync()

that makes the program freeze? It never returns from that while-loop? Why? It's hard to say what the code does...

Out of memory error?

 

Have to take a look at how libnds handles the interrupts, but here's mine:

 

void irqHandler(void) {

 if (REG_IF & BIT_IE_T3) {
// handle timer 3
Wifi_Timer(50);

// end
IRQ_CHECK |= BIT_IE_T3;
REG_IF |= BIT_IE_T3;
 }

 if (REG_IF & BIT_IE_IPC_FIFO_NOT_EMPTY) {
// handle IPC FIFO not empty
u32 i = REG_IPCFIFORECV;
if (i == 0x87654321)
  Wifi_Sync();

// end
IRQ_CHECK |= BIT_IE_IPC_FIFO_NOT_EMPTY;
REG_IF |= BIT_IE_IPC_FIFO_NOT_EMPTY;
 }

 if (REG_IF & BIT_IE_VBI) {
// handle vblank

// end
IRQ_CHECK |= BIT_IE_VBI;
REG_IF |= BIT_IE_VBI;
 }
}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...