working on mem card detecting
This commit is contained in:
@@ -241,9 +241,15 @@ MemoryCardManager* MEMCARDMAN = NULL; // global and accessable from anywhere in
|
|||||||
|
|
||||||
bool UsbChanged()
|
bool UsbChanged()
|
||||||
{
|
{
|
||||||
|
LOG->Trace( "USBChanged" );
|
||||||
|
|
||||||
|
|
||||||
// check PROC_KMSG for any "usb" messages
|
// check PROC_KMSG for any "usb" messages
|
||||||
if( fds_kmsg == -1 )
|
if( fds_kmsg == -1 )
|
||||||
|
{
|
||||||
|
printf("closed\n");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
fd_set fdset;
|
fd_set fdset;
|
||||||
FD_ZERO( &fdset );
|
FD_ZERO( &fdset );
|
||||||
@@ -254,15 +260,20 @@ MemoryCardManager* MEMCARDMAN = NULL; // global and accessable from anywhere in
|
|||||||
if ( select(max_fd+1, &fdset, NULL, NULL, &zero) <= 0 )
|
if ( select(max_fd+1, &fdset, NULL, NULL, &zero) <= 0 )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
LOG->Trace( "kmsg: fd isset" );
|
||||||
|
|
||||||
if( !FD_ISSET(fds_kmsg, &fdset) )
|
if( !FD_ISSET(fds_kmsg, &fdset) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
static char buffer[1024]; // large enough to read all messages in one call
|
printf( "kmsg: reading...\n" );
|
||||||
int ret = read(fds_kmsg, &buffer, sizeof(buffer));
|
|
||||||
|
|
||||||
|
static char buffer[1024]; // large enough to read all messages in one call
|
||||||
|
int ret = read(fds_kmsg, buffer, sizeof(buffer));
|
||||||
|
|
||||||
|
printf("kmsg: read %d bytes\n", ret );
|
||||||
if( ret == 0 )
|
if( ret == 0 )
|
||||||
{
|
{
|
||||||
LOG->Warn("Read only %d bytes from '%s'", ret, PROC_KMSG);
|
printf( "closing kmsg" );
|
||||||
close(fds_kmsg);
|
close(fds_kmsg);
|
||||||
fds_kmsg = -1;
|
fds_kmsg = -1;
|
||||||
return false;
|
return false;
|
||||||
@@ -276,10 +287,16 @@ MemoryCardManager* MEMCARDMAN = NULL; // global and accessable from anywhere in
|
|||||||
{
|
{
|
||||||
buffer[ret] = '\0';
|
buffer[ret] = '\0';
|
||||||
}
|
}
|
||||||
LOG->Trace( "read '%s' from kmsg", buffer );
|
char* temp = buffer;
|
||||||
|
while( *temp )
|
||||||
|
{
|
||||||
|
if( *temp<32 )
|
||||||
|
*temp = '\n';
|
||||||
|
temp++;
|
||||||
|
}
|
||||||
|
printf( "kmsg: '%s'", buffer );
|
||||||
|
|
||||||
bool bLogAboutUsb = strstr(buffer,"usb") || strstr(buffer,"USB");
|
return true;
|
||||||
return bLogAboutUsb;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemoryCardManager::Update( float fDelta )
|
void MemoryCardManager::Update( float fDelta )
|
||||||
|
|||||||
Reference in New Issue
Block a user