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

Not able to run tap scenario #390

Closed
yaphatak opened this issue Feb 28, 2017 · 16 comments
Closed

Not able to run tap scenario #390

yaphatak opened this issue Feb 28, 2017 · 16 comments
Labels

Comments

@yaphatak
Copy link

./fbsimctl <udid> tap 200.0 200.0. it always say Could not connect to HID, it must be provided on launch. I did pass hid port on launching simulator. Am I missing something?

@ssynix
Copy link

ssynix commented Feb 28, 2017

It only worked on --direct-launch for me.

@yaphatak
Copy link
Author

yes I am launching with fbsimctl <udid> boot --direct-launch -- listen --http 8090 --hid 4590

@lawrencelomax
Copy link
Contributor

This is correct. --direct-launch is required, but you must interact from the same process as boots the simulator.

The reason for this is that the process that is responsible for booting the simulator, owns the rights to write to the mach port that actually sends the HID events to the simulator. You can either use the HID Socket functionality to pump HID events to the simulator, or with the HTTP server. It's currently not possible to do this from another process.

@ssynix
Copy link

ssynix commented Mar 2, 2017

This is how I ended up sending a tap action through the socket in case you get the HID connection working. (--hid 8091)

echo '{"x":150,"y":100,"class":"touch","type":"down"}' | nc localhost 8091 && \
sleep 0.2 && \
echo '{"x":150,"y":100,"class":"touch","type":"up"}' | nc localhost 8091

@lawrencelomax
Copy link
Contributor

@ssynix that looks similar to what I have locally. A socket should work well with other languages like python, though I haven't gotten round to adding this to the fbsimctl e2e tests.

@yaphatak
Copy link
Author

yaphatak commented Mar 3, 2017

Sorry i was away for day. I just tests this and it works. thanks @ssynix & @lawrencelomax.
Do you have some documentation on using rest api like @ssynix showed or we have to dig into code

@ssynix
Copy link

ssynix commented Mar 3, 2017

There's pretty decent documentation in the header files and commit messages, so that's the first place I look.

For HID stuff, see here.

@yaphatak
Copy link
Author

yaphatak commented Mar 3, 2017

Thanks @ssynix . I will go through it.

@lawrencelomax
Copy link
Contributor

I'd like for this to eventually documented, but for now this API is in its early stages. I'm confident that keeping line terminated json will stay, as well as keeping the primitives the same. Higher level gestures can be built on top of this. For a real-time API, simple primitives make the most sense as it will be easy to convert to UI events in a browser or native application.

If there's anything else you'd like to know, please reopen.

@yaphatak
Copy link
Author

yaphatak commented May 2, 2017

@lawrencelomax I see protocol changed here. So tried this
echo '{"action":"hid","payload":{"x":112,"y":94,"class":"touch","direction":"down"},"udid":"285A2218-1FF6-4727-821A-785908A78584"}' | nc localhost 4570 && sleep 0.2 && echo '{"action":"hid","payload":{"x":112,"y":94,"class":"touch","direction":"up"},"udid":"285A2218-1FF6-4727-821A-785908A78584"}' | nc localhost 4570
I see that its not working anymore. It feels like this does long click rather than click. I removed sleep part it still doesn't help.
I also see that following in log. I have feeling it does same action twice
{"event_type":"started","timestamp":1493761660,"subject":{"y":94,"x":112,"class":"touch","direction":"down"},"event_name":"hid"} {"event_type":"ended","timestamp":1493761660,"subject":{"y":94,"x":112,"class":"touch","direction":"down"},"event_name":"hid"} {"event_type":"started","timestamp":1493761660,"subject":{"y":94,"x":112,"class":"touch","direction":"up"},"event_name":"hid"} {"event_type":"ended","timestamp":1493761660,"subject":{"y":94,"x":112,"class":"touch","direction":"up"},"event_name":"hid"}

@yaphatak
Copy link
Author

yaphatak commented May 2, 2017

actually issue was with my parsing logic. It still works :). Sorry to bother.

@sumitwy
Copy link

sumitwy commented May 30, 2017

Cannot pass hid port on launch. fbsimctl is not accepting hid port? Is something changed?

fbsimctl boot -- listen --hid 8490 doesn't work. However,
fbsimctl boot -- listen --http 2346 does.

Any ideas?

@ssynix
Copy link

ssynix commented May 30, 2017

Could you try booting with --direct-launch as suggested earlier?

@sumitwy
Copy link

sumitwy commented May 30, 2017

I have tried both (with and without --direct-launch).
Actually my problem is that fbsimtcl is not even able to parse --hid 8490 as valid input.

@ssynix
Copy link

ssynix commented May 30, 2017

One of the recent commits is: Change --hid to --socket
So give that a try!

@lawrencelomax
Copy link
Contributor

One of the recent commits is: Change --hid to --socket So give that a try

Good point, there has been a bunch of recent changes here. Main reason for doing so is that some of the functionality of fbsimctl (the binary) is being pushed down into the frameworks FBSimulatorControl/FBControlCore so that the remote interaction functionality can be placed in an arbitrary executable.

Additionally, the way that actions can be wired over a socket are being consolidated so that hid actions are not special snowflakes. Other actions such as launching an application can be sent over the same socket.

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

No branches or pull requests

4 participants