When running a game with `pdutil` The serial connection to Simulator doesn't seem to get fully established

I'm using a bash script on Mac to install & run my pdx. I'm using Mac SDK 2.5.0 wit device firmware 2.5.0. (earlier versions also affected)

After automatically rebooting into data disk mode, transferring files and rebooting again, I wait for the usb device to show up and then execute

pdutil /dev/cu.usbmodemPDU1_Y0<my serial> run "/Games/wheelsprung.pdx"

Here is a link to the full script:

This works and the game runs fine, but the Device Info panel in the sim shows a spotty connection to the device and the console window is spammed with cpu task percentages.
Note also that in the screenshot the cpu usages history is expected to show a constant historical usage rather than the spikes which are indicative of a bad connection.
Only when quitting my game, going to the launcher and then executing the exact same command again, a stable connection is achieved.
On thing I tried is inserting a few seconds of sleep before the pdutil run command, but that unfortunately didn't help

When using simulator to upload my game to device, this doesn't happen. The downsize of that method is that it's much slower and requires manual action

I was inspired by 2.5.0's changelog regarding usb serial, but unfortunately my problem persists.

Full script output:

 *  Executing task: ./scripts/quickinstall.sh 

PRODUCT wheelsprung
Bundle device PDX from source_dir wheelsprung.pdx to destination_dir wheelsprung_device.pdx
building file list ... done
.d..t.... ./
>f..t.... main.pdz
>f..t.... pdex.bin
>f..t.... pdxinfo
.d..t.... audio/level_select/
.d..t.... fonts/
.d..t.... images/
>f..t.... images/bike-chassis.pdt
>f..t.... images/bike-ghost-wheel.pdt
>f..t.... images/bike-wheel.pdt
>f..t.... images/gravity.pdt
.d..t.... images/flag/
.d..t.... images/killer/
>f..t.... images/level_select/level-status.pdt
.d..t.... images/rider/
>f..t.... images/rider/ghost-head.pdt
.d..t.... levels/

sent 207113 bytes  received 266 bytes  414758.00 bytes/sec
total size is 1316100  speedup is 6.35
Waiting for Data Disk to be mounted ... 
Game Dir mounted
building file list ... done
.d..tp... wheelsprung_device.pdx/
>f..tp... wheelsprung_device.pdx/main.pdz
>f..tp... wheelsprung_device.pdx/pdex.bin
>f..tp... wheelsprung_device.pdx/pdxinfo
.d...p... wheelsprung_device.pdx/audio/
.d...p... wheelsprung_device.pdx/audio/collision/
.d...p... wheelsprung_device.pdx/audio/engine/
.d...p... wheelsprung_device.pdx/audio/finish/
.d...p... wheelsprung_device.pdx/audio/kickstart/
.d..tp... wheelsprung_device.pdx/audio/level_select/
.d...p... wheelsprung_device.pdx/audio/menu/
.d...p... wheelsprung_device.pdx/audio/pickup/
.d...p... wheelsprung_device.pdx/audio/scream/
.d...p... wheelsprung_device.pdx/audio/suspension/
.d...p... wheelsprung_device.pdx/audio/thud/
.d..tp... wheelsprung_device.pdx/fonts/
.d..tp... wheelsprung_device.pdx/images/
>f..tp... wheelsprung_device.pdx/images/bike-chassis.pdt
>f..tp... wheelsprung_device.pdx/images/bike-ghost-wheel.pdt
>f..tp... wheelsprung_device.pdx/images/bike-wheel.pdt
>f..tp... wheelsprung_device.pdx/images/gravity.pdt
.d..tp... wheelsprung_device.pdx/images/flag/
.d..tp... wheelsprung_device.pdx/images/killer/
.d...p... wheelsprung_device.pdx/images/level_select/
>f..tp... wheelsprung_device.pdx/images/level_select/level-status.pdt
.d..tp... wheelsprung_device.pdx/images/rider/
>f..tp... wheelsprung_device.pdx/images/rider/ghost-head.pdt
.d..tp... wheelsprung_device.pdx/levels/

sent 206876 bytes  received 332 bytes  31878.15 bytes/sec
total size is 1316100  speedup is 6.35
Volume PLAYDATE on disk4s1 unmounted
Disk PLAYDATE ejected
Waiting for USB Device to be mounted ... 
ls: : No such file or directory
ls: /dev/cu.usbmodemPD*: No such file or directory
device 
ls: : No such file or directory
device /dev/cu.usbmodemPDU1_<redacted>
/dev/cu.usbmodemPDU1_<redacted>
Usb Device Connected
Running wheelsprung_device.pdx

You can't have two things competing for the PD serial port, it won't work. So if you're using pdutil you need to first quit the Sim or things will go sideways.

It would be nice to have the sim recover from this, considering pdutil is only active for a split second, but I do understand that this would be very low on your priority list.

So instead I'll add a step to the script to kill the sim before using pdutil, thanks

I found a workaround which is quite usable: Lock and unlock the device by triple-pressing the lock button.

This resets the usb connection, the connection to the simulator is restored

1 Like