Hello,
I'm new to PSP programming. I have a question about how to make sure my polling of the PSP serial port is synced.
First, is pspDebugSioGetchar() a blocking call? My assumption is 'no' based on the fact that it appears that the call returns -1 when there is 'nothing.'
This leads me to my second question. Suppose I have a 4800 baud communication device hooked up to my PSP (also set to 4800). Now, I want to poll the serial port. But, how do I make sure that my polls are synced to the available chars? For example, should I just,
while(condition)
{
ch = pspDebugSioGetchar();
// do something with ch
// ...
sceKernelDelayThread(1000000/4800);
}
And, does the SIO device have some kind of buffer so that if I, say, do something that takes 100ms, the next time I call Getchar(), I will get one that had been 'waiting' for a little bit?
I guess I'm asking, most simply: what is the canonical way to poll the serial port at an arbitrary baud rate?
Thank you,
~0
Noobish Question: pspDebugSioGetchar()
-
- Posts: 5
- Joined: Mon Sep 11, 2006 11:56 am
- Location: Worcester, MA
- Contact:
The PSP hardware has a small FIFO buffer, yes. The pspDebugSioGetchar function returns -1 if that buffer is empty, otherwise it removes and returns a character from the buffer. See pspsdk/src/debug/sio.c for the source.
A simple way to receive characters (at any baud rate) is to just treat any non-negative result as a character. See samples/debug/sio/main.c for an example, which looks like:
A more efficient way to do this (which avoids polling like that) is to use the serial interrupt. See psplink source and the discussion starting around this post.
A simple way to receive characters (at any baud rate) is to just treat any non-negative result as a character. See samples/debug/sio/main.c for an example, which looks like:
Code: Select all
while(1) {
ch = pspDebugSioGetchar();
if(ch >= 0) {
pspDebugScreenPrintf("Received %\n", ch);
}
}
-
- Posts: 5
- Joined: Mon Sep 11, 2006 11:56 am
- Location: Worcester, MA
- Contact: