[Samsung Epic 4G Touch] autoprime:
Confirmed working on the SPH-D700 Epic 4g, SPH-D710 Epic 4G Touch, SPH-L700/SCH-I515 Galaxy Nexus and SPH-L710 Galaxy S III

I have a DIAG script for the LG Optimus G LS970 here.

No more flashing back to Touchwiz! The following scripts enable USB Modem/Diag mode in AOSP roms(CM9/CM10/AOKP/etc). For those new to this, USB Modem mode is used to interface with Windows CDMA tools such as QPST, QXDM, DFS and CDMA Workshop. Modem mode has always been possible in stock Touchwiz roms using dialer codes. The issue has been AOSP roms not working with the modem mode dialer codes... requiring flashing back to stock TW to use it.

<--------- Doesn't work in AOSP

Few examples of what modem mode could be used for:

[HOW-TO][FIX] Repair your IMEI with QPST - updated w/ info

[How To] Upload a custom PRL to your Epic Touch 4G

[CDMA] 威盛 VIA Repair and Reprogramming

You can use a script manager to run the script. Open script manager, browse to script files on SD card, select script, set to run as SU and hit save. Do this with both scripts. Now you can use the script manager in the Widgets section to create shortcuts on the desktop for easy access. Hopefully these scripts get built into CM10 so this method is no longer needed.

You may or may not have to unplug/plugin the usb cable after new mode is set.

Samsung Epic 4G SPH-D700

Use in terminal emulator/adb or add to script.

**As of Oct 1, 2012... all SPH-D700 CM10 builds have working diag mode via *#*#8778#*#* menu thanks to bbelos. Script is not longer needed on those roms.**

**The SPH-D700 script below is confirmed working on the official TeamEpic CM9 builds**

Modem

echo MODEM USB > /sys/class/sec/switch/usb_sel

PDA

echo PDA USB > /sys/class/sec/switch/usb_sel

Samsung Epic 4G Touch SPH-D710

E4GT is working but being picky. If not detected in QPST correctly... connect phone to USB cable. While phone is in normal USB PDA mode open up QPST Service Programming > Server > Stop QPST Server. Now run the CP script(or run the commands in terminal emulator as SU) then pull out the USB cable then put it back in. Wait a second.. you should see a serial port being detected in Windows Device Manager. After port has been added and drivers installed.. go back to QPST Service Programming and enable the QPST Server. Your device should now be detected properly. If you disconnect your phone while QPST Server is running you will have to toggle it off/on again for the phone to show back up.

CP

#/system/bin/sh

echo 0 > /sys/class/android_usb/android0/enable
echo CP > /sys/class/sec/switch/set_usb_path
echo 1 > /sys/class/android_usb/android0/enable

CP v2

thx2squash

#/system/bin/sh

echo 0 > /sys/class/android_usb/android0/enable
echo disable_wimax > /sys/devices/platform/i2c-gpio.17/i2c-17/17-0008/port
echo enable_cp > /sys/devices/platform/i2c-gpio.17/i2c-17/17-0008/port
echo disable_ap > /sys/devices/platform/i2c-gpio.17/i2c-17/17-0008/port
echo CP > /sys/class/sec/switch/set_usb_path
echo 1 > /sys/class/android_usb/android0/enable

ALL (AP+CP)

#/system/bin/sh

echo 0 > /sys/class/android_usb/android0/enable
echo ALL > /sys/class/sec/switch/set_usb_path
echo 1 > /sys/class/android_usb/android0/enable

AP

#/system/bin/sh

echo 0 > /sys/class/android_usb/android0/enable
echo AP > /sys/class/sec/switch/set_usb_path
echo 1 > /sys/class/android_usb/android0/enable

AP v2

thx2squash

#/system/bin/sh

echo 0 > /sys/class/android_usb/android0/enable
echo disable_wimax > /sys/devices/platform/i2c-gpio.17/i2c-17/17-0008/port
echo enable_ap > /sys/devices/platform/i2c-gpio.17/i2c-17/17-0008/port
echo disable_cp > /sys/devices/platform/i2c-gpio.17/i2c-17/17-0008/port
echo AP > /sys/class/sec/switch/set_usb_path
echo 1 > /sys/class/android_usb/android0/enable

Samsung Galaxy Nexus (Sprint/Verizon)

Script works great for me on my Sprint Gnex. Varied reports about script working on Verizons. If script fails use terminal emulator instead.

MODEM

#/system/bin/sh

echo 0 > /sys/class/android_usb/android0/enable
echo MODEM > /sys/devices/tuna_otg/usb_sel
echo 1 > /sys/class/android_usb/android0/enable

PDA

#/system/bin/sh

echo 0 > /sys/class/android_usb/android0/enable
echo PDA > /sys/devices/tuna_otg/usb_sel
echo 1 > /sys/class/android_usb/android0/enable

Samsung Galaxy S III (Sprint/Verizon/US Cellular/AT&T/T-Mobile)

Use the script!

DIAG+ADB

#/system/bin/sh

# sets DIAG mode
echo 0 > /sys/class/android_usb/android0/enable
echo 04E8 > /sys/class/android_usb/android0/idVendor
echo 6860 > /sys/class/android_usb/android0/idProduct
echo diag > /sys/class/android_usb/android0/f_diag/clients
echo 1 > /sys/class/android_usb/android0/f_acm/instances
echo diag,acm,adb > /sys/class/android_usb/android0/functions
echo 1 > /sys/class/android_usb/android0/enable
start adbd

MTP+ADB

#/system/bin/sh

# sets default USB mode
echo 0 > /sys/class/android_usb/android0/enable
echo 04E8 > /sys/class/android_usb/android0/idVendor
echo 6860 > /sys/class/android_usb/android0/idProduct
echo 1 > /sys/class/android_usb/android0/f_acm/instances
echo mtp,acm,adb > /sys/class/android_usb/android0/functions
echo 1 > /sys/class/android_usb/android0/enable
start adbd

Samsung Galaxy S IV (Should work on ATT, Tmo, Sprint, Verizon, Cricket etc...)

DIAG+ADB

#/system/bin/sh

#reboot phone to disable

#enables diag mode
echo "0" /sys/class/android_usb/android0/enable
echo "04E8" /sys/class/android_usb/android0/idVendor
echo "685D" /sys/class/android_usb/android0/idProduct
echo "diag,diag_mdm" /sys/class/android_usb/android0/f_diag/clients
echo "hsic" /sys/class/android_usb/android0/f_acm/acm_transports
echo "diag,acm,adb" /sys/class/android_usb/android0/functions
echo "1" /sys/module/ci13xxx_msm/parameters/streaming
echo "1" /sys/class/android_usb/android0/enable

Original post has been removed since this has been solved. For reference it has been moved to post 5.