idb icon indicating copy to clipboard operation
idb copied to clipboard

Not able to run tap scenario

Open yaphatak opened this issue 9 years ago • 16 comments

./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?

yaphatak avatar Feb 28 '17 22:02 yaphatak

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

ssynix avatar Feb 28 '17 22:02 ssynix

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

yaphatak avatar Feb 28 '17 22:02 yaphatak

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.

lawrencelomax avatar Mar 02 '17 17:03 lawrencelomax

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

ssynix avatar Mar 02 '17 18:03 ssynix

@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.

lawrencelomax avatar Mar 02 '17 21:03 lawrencelomax

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

yaphatak avatar Mar 03 '17 22:03 yaphatak

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.

ssynix avatar Mar 03 '17 23:03 ssynix

Thanks @ssynix . I will go through it.

yaphatak avatar Mar 03 '17 23:03 yaphatak

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.

lawrencelomax avatar Mar 05 '17 12:03 lawrencelomax

@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 avatar May 02 '17 21:05 yaphatak

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

yaphatak avatar May 02 '17 22:05 yaphatak

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?

sumitwy avatar May 30 '17 12:05 sumitwy

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

ssynix avatar May 30 '17 13:05 ssynix

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.

sumitwy avatar May 30 '17 13:05 sumitwy

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

ssynix avatar May 30 '17 13:05 ssynix

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.

lawrencelomax avatar May 30 '17 18:05 lawrencelomax