Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portal Incompatibility? #12

Open
hegyak opened this issue Nov 26, 2016 · 22 comments
Open

Portal Incompatibility? #12

hegyak opened this issue Nov 26, 2016 · 22 comments

Comments

@hegyak
Copy link

hegyak commented Nov 26, 2016

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
Copy link
Owner

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
Copy link
Author

hegyak commented Nov 28, 2016

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
Copy link

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
Copy link
Author

hegyak commented Nov 28, 2016

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
Copy link
Owner

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
Copy link
Contributor

jtp10181 commented Nov 30, 2016 via email

@hegyak
Copy link
Author

hegyak commented Dec 1, 2016

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
Copy link
Owner

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
Copy link
Author

hegyak commented Dec 5, 2016

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
Copy link
Owner

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
Copy link
Author

hegyak commented Dec 5, 2016

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 added a commit that referenced this issue Dec 5, 2016
@silicontrip
Copy link
Owner

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
Copy link
Author

hegyak commented Dec 5, 2016

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
Copy link
Owner

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
Copy link
Author

hegyak commented Dec 6, 2016

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
Copy link

capull0 commented Dec 30, 2016

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
Copy link

SpiderSensei commented Jan 15, 2017

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
Copy link

capull0 commented Jan 19, 2017

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
Copy link
Owner

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

@capull0
Copy link

capull0 commented Jan 22, 2017

i created a pull request
#17

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

@jekarellas
Copy link

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants