Closed matthewbullweb closed 7 years ago
While the Toypad class processes the protocol to communicate with the toypad, toypadEmu is for communicating as the toypad. I have it running on a Raspberry Pi Zero that has been programmed to pretend to be the portal when connected to my WiiU. Therefore I have total control over what data the WiiU gets from the emulated portal. (AKA: placing characters without having an actual portal)
Ok that explains a lot. Would be intrested in how this is setup.
Saw an older video for Disney Infinity which used 2 itzy (unsure of spelling) USB HID emulators connected to each other and a laptop. Also had a passthrough for Xbox 360 version of base. https://youtu.be/6MNwy_pa35A
Thought it could be intresting for you.
itzy
connected to each other and a laptop.
I actually bought two small boards like that after seeing that video. :) After failing at avr coding, (I am not good at hardware coding) I switched to an Odroid C1+ and uses its OTG port. Then it was discovered that the Pi Zeros OTG port is usable. The Pi has an advantage of a mainline kernel so was much easier to deal with I'm using a kernel that Adafruit compiled with CONFIGFS support, which allows me to have a basic script to setup USB emulation. (Also works on ANY linux device with CONFIGFS and OTG support)
Glad this was of use. Will be trying to get a Pi Zero once they come back in stock. Really intrested in seeing how this works.
Have a Pi Zero now and ordered a USB to TTL serial cable so I can still connect when board usb is in use. Taught myself how to run scripts at startup with Linux (as service). Will try keyboard HID elum first and more up from there. Am I taking the right path?
Yes. :) Also, the main kernel has configfs support now, so that makes it easier. (No custom kernel needed) Heres the script I used to setup the usb gadget, it creates a device at /dev/hidg0 than can be read/written like a file. http://pastebin.com/TpJvZJtP
Notice toypadEmu.js is no longer in latest samples. Use older version of node-ld and got following error. Any ideas?
pi@pizero:~/node-ld-master1/samples $ sudo node toypadEmu.js
module.js:340
throw err;
^
Error: Cannot find module 'lodash'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.
Sorry about that, I imported a ton of repos from my private git server when github changed to unlimited private repos, it looks like it pushed the node-ld from there which rolled it all back. I have re-pushed the correct repo so it should work now. Also note that it can be easily installed by npm install node-ld
too ;)
Hi,
Took me a while to find out how to update node and npm. Once I managed to do that and ran the command alot of errors came up. Think i'll try again next weekend. Screen output and logs attached for reference.
From what I can tell, it looks like you've got the distro gyp program installed which is outdated, it comes bundled in npm. try
sudo apt-get remove gyp
npm explore npm -g -- npm install node-gyp@latest
Hi, I believe I managed to finally update all the parts needed. The command above removes npm and nodejs needs removing and reinstalling to fix. Founnd node-gyp install/update works.
The output was the following
pi@pizero:~/script/ld $ sudo bash setup --2016-05-21 21:55:04-- http://repo.ags131.com/install.sh Resolving repo.ags131.com (repo.ags131.com)... 192.99.32.89, 2607:5300:60:4759:: Connecting to repo.ags131.com (repo.ags131.com)|192.99.32.89|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 181 [application/octet-stream] Saving to: ‘STDOUT’
2016-05-21 21:55:05 (3.08 MB/s) - written to stdout [181/181]
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.zfXgmeCnEF --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --fetch-keys http://repo.ags131.com/repo.ags131.com.gpg.key gpg: key E334008C: "Adam Shumann ashumann13@gmail.com" not changed gpg: Total number processed: 1 gpg: unchanged: 1
Hi, had some success with usb serial and ethernet devices. Will try to setup something I found called a "g probe" (gadget probe). Looks very simular to one provided in a past comment .Why does your script remove a number of modules at the end?
the script removes the other modules as they conflict, libcomposite is the one exception, it ends up reloaded
I keep getting "usb device descriptor failed" message from pi zero. Maybe i do need to switch out kernel. USB serial cable blue screened my computers and have returned that. Will give up for now. Did write a script node-js npm gyp update script which worked. Also descovered two pi's can communicate between serial connections. Thought far top left pins on pi zero back were for lan but after researching found out its for teensy.
Hi, managed to get the pizero to show as a lego 2.0 reader. PC is asking for driver though (real base does not). Also read up and there could be something missing. Possably a little c program to allow node to talk to HID devices (dev folder)
Using configfs it should create a /dev/hidg0 device, node-ld automatically uses that for toypademu. Make sure your configfs only has a HID device added, and not ecm or acm.
Can you help me :) ?
OS: Windows 7 x64 Nodejs: 4.1.2 files.zip
C:\?\?\?\node-ld-master\node-ld\samples>node toypademu C:\?\?\?\node-ld-master\node-ld\dist\lib\ToyPadEmu.js:53 if (!opts.transport && opts.transport !== false) opts.transport = new ld.transports.RawTransport('/dev/hidg0');
^
ReferenceError: ld is not defined
at new ToyPadEmu (C:\?\?\?\node-ld-master\node-ld\dist\lib\Toy
PadEmu.js:53:73)
at Object.
toypadEmu will not work on windows unless using a socket based transport (TCP, UDP, etc).
So i try to install it on a RPI Zero , but the same issue.
OS: Raspbian Jessie 2016-05-27 Nodejs: 4.1.0
http://img5.fotos-hochladen.net/uploads/bild11mu2jhvpcx.png
I also had a problem when generate the dist folder . The install script runs through clean , but lacks the dist folder . I have both sudo npm install node- ld , and sudo npm install attempts .
It would be great if you can help me :) .
OK, just ran it on my end, and for some reason ld is undefined, you can solve this by editing toypadEmu.js to have
var tp = new ld.ToyPadEmu({
transport: new ld.transports.RawTransport('/dev/hidg0')
})
Funny, i had the same problem. Got the piZero to should up. Hopefully this will be the last piece of the puzzle.
The problem is thus solved , thanks for that .
Here already is the next error ; ( .
pi@raspberrypi:~/lego/node_modules/node-ld/samples $ sudo node toypadEmu.js /home/pi/lego/node_modules/node-ld/dist/lib/ToyPadEmu.js:60 _this.burtle = new ld.Burtle(); ^
ReferenceError: ld is not defined
at new ToyPadEmu (/home/pi/lego/node_modules/node-ld/dist/lib/ToyPadEmu.js:60:22)
at Object.
I patched ToyPadEmu and did a push, looking at file history it got broke when I standardized to ES6 classes everywhere. It should be working now, I can't easily test as I'm at work right now.
should be a simple npm install node-ld
to update
Ok , now he wants firstonce install :) .
I thank you in any case for your quick and good help !
The emulator seems to work, but he is very buggy. Now I have to ask whether it is up to the software or the hardware.
My problem is that the emulator works sometimes and sometimes not. Time will come all the figures and another time comes from only one part.
I suspect the error comes from the module libcomposite. Your script tries to quit, but that is not possible.
$ Rmmod: ERROR: Module libcomposite is in use by: usb_f_hid
When I start the Raspberry I am able to quit the module libcomposite. But that disappears the "/ sys / kernel / config / usb_gadget" and I can not use the emulator.
I use the PS3. Do you have an idea?
Best wishes chaos
One thing I have noticed, if adding and removing figures too rapidly, the game will ignore some of them, try adding a delay between placing/removing multiple. Also, while that script does try to remove libcomposite, libcomposite should not be removed. I've since corrected that in newer copies of the script.
Ok I'll try it.
Thanks anyway for this emulator :) .
Ran these two commands after installing node. One does not appear to do anything but the other returns an error. I am using raspbian jessie lite.
pi@pizero1:~/node-ld/samples $ node toypadEmu.js pi@pizero1:~/node-ld/samples $ nodejs toypadEmu.js
module.js:340
throw err;
^
Error: Cannot find module './dist/node'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.
Finally got the correct version of node and this worked in my pi zero. Ran your npm install command but could only run from .stage folder. Used js timeouts to add delays between tags.
Suggested improvement is to have interactive script for pre defined tags. E.g. press 1 for batman then the number of pad to place it on.
Notice certain character ids don't work. E.g. Shaggy clear all characters off base.
Thanks for the hard work.
The samples are more meant to help others create the more useful tools, this is mostly just an API
usual install would be to run npm install node-ld
in a project folder ;)
Can the emulator only cope with one character and one vehicle at a time?
Managed to work out how to swap pads. Think UID will need to be the same for swapped character (lets say between pad 2 to 1).
It can handle upto 7 vehicles/characters at a time
They each have to have a unique UID though
When swapping pads, call tp.remove(token)
then tp.place(token,newID,index,uid)
to place that same token on a different pad. Note that index MUST be unique among the tokens and from 0-6
Tokens cannot share an index.
Ok thanks. tp.remove accept a string which i believe to be token.uid and character is not removed. Maybe I am giving it the wrong value. When I do another tp.place the existing character is taken off. Not sure if this should happen.
remove accepts either the index or the original token object
Hello ags131, I would like to offer you a small gift for your hard work. Your example script for the emulator I have a little expanded.
With this script it is possible to implement a meaningful administration of the characters.
The script can: - manage the tags
There are 3 "commands" for the control:
Some information:
Hello ags131,
Can you help me with two problems?
Unfortunately without man in the middle it is not possible to recognize the errors. It could be the missing data in the tag of the figure itself. Or there is a problem with the encryption.
Otherwise, I have created a webserver, which serves as frontend for the control of the emulator (drag and drop). The emulator now also has the functions for color management. The colors are sent to the website in relative real time.
I did the MITM using an ODroid C1+ with the OTG Port, but it can also be done with a Pi0 + IoT Hat or the CHIP
Hi ags131,
Love your toypadEmu files, just got them working today and they're great!
One question though,
You said that the tp.place
syntax is like this:
tp.place(token,id,index,uid)
I get what token and uid do, but what about id and index?
Thanks,
2BoysAndHats
Thanks to this project I learned a lot about the communication with the portal and about NFC tags. I even were able to set up a USB gadget to emulate the portal. (Using the real figures is way more fun!) Nevertheless, chaos363 was right with placing characters is brittle. Was there any improvement on that? @chaos363 Would you provide the updated version of your ToyPadEmu with the web interface ? @ags131 Might it be that the portal won't write any pages equal to or higher than page 28(hex) ?
Just wondering how the toypadEmu js files are used. Not fimiular with Hex and also tried playing with charCryptoExample.js to no avail. Thinking maybe theses are not for pc or used with the toypad base. Looking for a little direction.