silicontrip / SkyReader

A Skylander portal reader/editor/writer for OSX.
89 stars 56 forks source link

Portal Incompatibility? #12

Open hegyak opened 7 years ago

hegyak commented 7 years ago

I having trouble getting the editor to work correctly. I have tried a Swap Force portal for XBox 360 and a Trap Team portal for PS4, and neither one works correctly.

The XBox 360 portal isn't found by the editor. The PS4 Portal does identify but, it doesn't read any character data.

The PS4 Console log says, "Reading Skylander" Then it says, "Found portal usb device"

Then nothing happens

Is there a particular portal I should use to make this work? What Game and System?

silicontrip commented 7 years ago

It is documented that XBOX peripherals will not work. Xbox peripherals contain additional encryption hardware to tie them to the Xbox and cannot be used with other platforms and also prevent other platforms peripherals working with the Xbox. (apparently there is software about to talk to Xbox peripherals but it is not cross platform)

The PS4 portal sounds like it is working. I assume you have a skylander on the portal. What is the command line arguments you are using. What operation are you wishing to perform?

hegyak commented 7 years ago

I entered the command: skyreader -p -o Cynder.bin

I also tried: skyreader -p -o robot.bin

I wanted to read in the character's data onto my PC. Preferably decrypted.

I did run the program from an administrator console on Windows. I have installed the PS4 with the drivers and the device is recognized by Device Manager. I also used HidTest to verify that the Portal does show on the Device list.

I am attempting to read the Giant Robot for Giants (I can't remember it's name) and a Crystal variant of Cynder for Swap Force.

macgayverarmini commented 7 years ago

But have you compiled from the source code posted here for windows? Or are you using the version compiled by others running on the internet?

How did you compile on windows? I just managed to compile on OSX ...

hegyak commented 7 years ago

I compiled the code using: mingw32-make -f Makefile.mingw

as the Makefile.mingw file specified.

The same issue with the PS4 portal still exists for me.

silicontrip commented 7 years ago

Does it appear to crash out or exit normally? I'm sorry I don't know what indication you get when an application crashes in windows, do you get some sort of message or core dump? Do you end up with the .bin file as you specified (even if it is 0 bytes) Do you have a debugger you can run it under?

jtp10181 commented 7 years ago

I have never been able to get it to read from the portal under Windows either.... I spent days trying to figure it out.

On Tue, Nov 29, 2016, 9:53 PM Mark Heath notifications@github.com wrote:

Does it appear to crash out or exit normally? I'm sorry I don't know what indication you get when an application crashes in windows, do you get some sort of message or core dump? Do you end up with the .bin file as you specified (even if it is 0 bytes) Do you have a debugger you can run it under?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/silicontrip/SkyReader/issues/12#issuecomment-263776542, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGFD4q_DXMcM_vRwwogZbLDgZNeEXbVks5rDPNEgaJpZM4K89TN .

hegyak commented 7 years ago

This program doesn't get beyond "Found portal usb device"

I tried the other Skylander Editor and it worked fine. Trap Team portal for PS4, Windows 7, Giants Robot. Data read in properly. No issues.

silicontrip commented 7 years ago

Did you want me to make a debug version for you so we can find out why this version isn't working or are you happy with the other version? I did originally write this version to work on OSX based on a windows program I found online. I happened to use a cross platform USB library which would help it build under Linux and Windows. Other people have forked this project to get it to build on those platforms. I don't have access to these platforms to test this code against it. Plus my son sold his Wii and bought an xbox so I don't really have the ability to test the OSX version anymore.

hegyak commented 7 years ago

I woudn't mind using a debug version to determine what's going on here. Even that old version that you probably used as the code base, has issues reading data sometimes. And that's with the PS4 portal. If I can help debug/fix problems, I will be quite happy to get it to happen.

silicontrip commented 7 years ago

I've started a debug branch, I've put some messages in the most likely places it is failing. See if it builds and let me know what the output of this version is. I've also seen some other options which might give more insight into what is happening.

Can you run it with the "-l" option ?

hegyak commented 7 years ago

I compiled the Debug branch and this is the message I got:

Found portal usb device ">>> PortalIO::Write" <<< PortalIO::Write ">>> PortalIO::Write" <<< PortalIO::Write

The PortalIO:Write messages repeats constantly.

I am using the PS4 Trap Team Portal with Cynder (Giants) for the first read test and Spyro (Adventures) for the second read test. Having no Skylander on the Portal, causes the same messages.

Edit: I had to add the quote marks. They do not appear in the Debug log.

silicontrip commented 7 years ago

I've narrowed it down. It appears that the code is waiting for the correct response from the portal. I do not know what the portal is responding with nor do I know why the expected response isn't received.

I've added more debugging to print out the response from the portal. However it might be a peculiarity with the PS4 portal.

hegyak commented 7 years ago

I used a PS3/Wii portal for Swap Force.

Command I used: editor -l

Message from the Console: Listing Skylanders.

Found portal usb device

PortalIO::Write <<< PortalIO::Write throw 6 Unable to write to Portal.

The PS4 Trap Team Portal gave me a longer but still repeating console message. PS4.txt

The Xbox 360 Portals require special Driver software. To get them to work. Unsure if I should try them at all. I have the drivers if you want me to give that a try as well.

silicontrip commented 7 years ago

It appears that the portal is sending back a status response and not a query skylander response. I've restored some code that is supposed to activate the portal first. Maybe it might help.

hegyak commented 7 years ago

The portal still does not behave as it should. Same error messages as before.

Edit: the spec.txt file says:

"The protoocol couldn't be simpler -- the first byte of the data is a character representing the command, and then the data comes after it. For the wired version, 0B 14 is placed before the command character."

However, I wasn't able to find 0B 14 being sent along with the command characters. Could that be the reason it won't read? I know for sure that I am using Wired Portals.

capull0 commented 7 years ago

i figured out why some portals are not working. a imaginators portal always sends: P: 81 53 00 00 00 00 24 01 00 00 00 00 00 00 00 00 .S....$......... 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 . the first request is a report request: PS3: 21 09 00 02 00 00 02 00 52 00 !.......R. and the answer: P: 81 52 02 0a 05 08 00 00 00 00 00 00 00 00 00 00 .R.............. 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 .

a swap-force/Superchargers portal with send following status: P: 81 53 00 00 00 00 28 00 00 00 00 00 00 00 00 00 .S....(......... 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 .
you can see the 0x00 after the counter. it will not reply to any requests (R, A, Q ...)

i think you have to send something to the portal to change the device status.

SpiderSensei commented 7 years ago

I'm having the same issue with a superchargers portal. I'm not sure what @capull0 is referring to as "always sends...". Is this the device descriptor packet dumped in hex? Experienced dev happy to help track down what's going on if I can find some resources (info on request structures would be especially helpful) to start from

EDIT: I found the SkylandersGUITool which seems to have no issues whatsoever communicating with this portal. Fired up USBlyzer to check out the differences, it doesn't look like hidapi is working correctly. hid_write specifically is sending a bulk transfer write instead of a Class Interface SetReport. I suspect this is the reason calls are now failing - at some point they may have removed support for the bulk transfer endpoint. Looking into whether it's possible to modify hidapi (hid_win.c specifically) to get this working.

EDIT2: Found the solution. MSDN Documentation is somewhat lacking in this area (somewhat expected, given the low level of work). The windows implementation of hidapi uses WriteFile to implement hid_write which is translated into a bulk transfer operation. The library seems to be entirely missing a separate way of writing smaller requests - the closest is hid_send_feature_report. I'm not exactly a USB expert but I think there are differences between feature reports and other report types (the difference between HidD_SetOutputReport and HidD_SetFeature, I'd imagine).

This can easily be fixed by a patch to hid_win.c, I'll try to put together a Pull Request once I fix some other things that are broken.

capull0 commented 7 years ago

thanks SpiderSensei for the hint.

i figured out the problem. the (R)eport-, (A)ctivate- and (Q)uerie-requests are sended via "Interrupt Transfer". My Imaginators PS3 portal is answering such requests.

But all other portals, for example from Superchargers doesn't reply to "Interrupt Transfer". I changed the hid_linux.c to use always "Control Transfer" and it's working with all PS3 portals from my son.

$ git diff hid_linux.c
diff --git a/hid_linux.c b/hid_linux.c
index 0a9bccf..a422d33 100644
--- a/hid_linux.c
+++ b/hid_linux.c
@@ -900,7 +900,8 @@ int HID_API_EXPORT hid_write(hid_device *dev, const unsigned char *data, size_t
     }

-    if (dev->output_endpoint <= 0) {
+   // if (dev->output_endpoint <= 0) {
+    if (1) {
         /* No interrput out endpoint. Use the Control Endpoint */
         res = libusb_control_transfer(dev->device_handle,
                                       LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE | LIBUSB_ENDPOINT_OUT,
silicontrip commented 7 years ago

Now if I could patch and test this on OSX. Has this been reported to libhid?

capull0 commented 7 years ago

i created a pull request https://github.com/silicontrip/SkyReader/pull/17

libhid is not the issue. most of the skylanders portals don't like interrupt transfer.

jekarellas commented 7 years ago

I got to work SkyReader on Windows 10 64 bit! I used capull0 fork Its dont work with my PS4 trap Team portal (UNABLE WRITE TO PORTAL) With PS3 Giants portal Skyreader work perfect ! Thanks !

my video proof https://www.youtube.com/watch?v=MYIjAngqAxY&feature=youtu.be

pkolmann commented 7 years ago

I can confirm that the version from capull0 works on my Win10 64bit as well.