Skip to content

Commit

Permalink
fix for 6.60
Browse files Browse the repository at this point in the history
  • Loading branch information
173210 committed Apr 4, 2014
1 parent 03dac27 commit d0a7037
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 62 deletions.
37 changes: 22 additions & 15 deletions netshell/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,21 @@ void ttySetWifiHandler(PspDebugPrintHandler wifiHandler);

int g_currsock = -1;
int g_servsock = -1;
int g_size = 0;
char g_data[4096];

#define SERVER_PORT 10000

int wifiPrint(const char *data, int size)
{
if(g_currsock >= 0)
{
sceNetInetSend(g_currsock, data, size, 0);
while(g_size)
{
sceKernelDelayThread(4096);
}
memcpy(g_data, data, size);
g_size = size;
}

return size;
Expand Down Expand Up @@ -135,17 +142,21 @@ void start_server(const char *szIpAddr)

while(1)
{
readbytes = sceNetInetRecv(new, &data, 1, 0);
if(readbytes <= 0)
{
sceNetInetClose(new);
g_currsock = -1;
printf("Socket %d closed\n", new);
break;
if(g_size) {
if(sceNetInetSend(new, g_data, g_size, 0) < 0)
{
sceNetInetClose(new);
g_currsock = -1;
printf("Socket %d closed\n", new);
break;
}
g_size = 0;
}
else

readbytes = sceNetInetRecv(new, &data, 1, MSG_DONTWAIT);
if(readbytes >= 0)
{
if((data == 10) || (data == 13))
if ((data == 10) || (data == 13))
{
if(pos > 0)
{
Expand All @@ -159,18 +170,14 @@ void start_server(const char *szIpAddr)
g_currsock = -1;
psplinkExitShell();
}
psplinkPrintPrompt();
}
}
else if(pos < (sizeof(cli) -1))
{
cli[pos++] = data;
}
else
{
/* Do nothing */
}
}
sceKernelDelayThread(4096);
}
}

Expand Down
10 changes: 5 additions & 5 deletions psplink/psplink.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Example psplink configuration file.

# usbmass=[0 1] Enable USB mass storage. Set to 1 to enable automatically
usbmass=1
usbmass=0

# usbhost=[0 1] Enable USB host file system. Set to 1 to enable automatically
usbhost=0
Expand All @@ -18,18 +18,18 @@ pluser=1
resetonexit=1

# sioshell=[0 1] Specify whether to start up the sio shell
sioshell=1
sioshell=0

# kprintf=[0 1] Specify that SIO should be used for kprintf only, setting sioshell
# to 1 overrides this setting.
kprintf=1

# wifi=[0..N] Specify wifi should be enabled, the number is the
# configuration to use if > 0
wifi=0
wifi=1

# wifishell=[0 1] Specify whether to start up the wifi shell
wifishell=0
wifishell=1

# usbshell=[0 1] Specify whether to start up the usb shell
usbshell=0
Expand Down Expand Up @@ -61,7 +61,7 @@ consupcmd=cop0

# prompt=... Set the psplink shell prompt
# There are some escape characters, mainly %d to print the current dir
prompt="%d> "
prompt=" %d> "

# path=... Set the psplink shell path
# Each path is separated by a semi-colon, you can specify up to around 128 characters
Expand Down
43 changes: 1 addition & 42 deletions psplink/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ static int g_currcli_pos = 0;
static SceUID g_command_msg = -1;
/* Thread ID for the command line parsing */
static SceUID g_command_thid = -1;
/* Semaphore to lock the cli */
static SceUID g_cli_sema = -1;
/* Event flag to indicate the end of command parse */
static SceUID g_command_event = -1;
/* Indicates the name of the last module we loaded */
static char g_lastmod[32] = "";
/* Indicates we are in tty mode */
Expand Down Expand Up @@ -4174,7 +4170,7 @@ static int shellParseThread(SceSize args, void *argp)
{
msg->res = CMD_ERROR;
}
sceKernelSetEventFlag(g_command_event, COMMAND_EVENT_DONE);
print_prompt();
}

return 0;
Expand All @@ -4185,37 +4181,14 @@ int psplinkParseCommand(char *command)
u32 k1;
int ret;
CommandMsg msg;
SceUInt timeout = (10*1000*1000);

k1 = psplinkSetK1(0);

ret = sceKernelWaitSema(g_cli_sema, 1, &timeout);
if(ret < 0)
{
printf("Error, could not wait on cli sema 0x%08X\n", ret);
return 1;
}

memset(&msg, 0, sizeof(msg));
msg.command = command;
msg.res = 0;
ret = sceKernelSendMbx(g_command_msg, &msg);
if(ret >= 0)
{
u32 result;
ret = sceKernelWaitEventFlag(g_command_event, COMMAND_EVENT_DONE, 0x21, &result, NULL);
if(ret >= 0)
{
ret = msg.res;
}
else
{
printf("Error waiting for parse event 0x%08X\n", ret);
ret = CMD_EXITSHELL;
}
}

sceKernelSignalSema(g_cli_sema, 1);
psplinkSetK1(k1);

return ret;
Expand Down Expand Up @@ -4600,20 +4573,6 @@ int shellInit(const char *cliprompt, const char *path, const char *init_dir, con
return -1;
}

g_cli_sema = sceKernelCreateSema("PspLinkCliSema", 0, 1, 1, NULL);
if(g_cli_sema < 0)
{
printf("Error, couldn't create cli semaphore 0x%08X\n", g_cli_sema);
return -1;
}

g_command_event = sceKernelCreateEventFlag("PspLinkCmdEvent", 0, 0, NULL);
if(g_command_event < 0)
{
printf("Error, couldn't create command event 0x%08X\n", g_command_event);
return -1;
}

if(strlen(startsh) > 0)
{
ret = sceKernelStartThread(g_command_thid, strlen(startsh)+1, (void*) startsh);
Expand Down

0 comments on commit d0a7037

Please sign in to comment.