I am working on an Android project that will connect to an Xbox 360 controller. I want to be able to capture user feedback via the controller's input reports. I am using Virtual Box and AndroidVM for testing and have used the following for reference to the USB protocol (especially as it pertains to the Xbox controller):
http://free60.org/GamePad
http://www.beyondlogic.org/usbnutshell/usb3.shtml#USBProtocols
To name a few of the links I am using for information. I have also referenced HID protocol information to examine the packet descriptions.
I have successfully been able to detect and enumerate the controller via the VM AND have been successful in obtaining input reports using the Android SDK API (e.g. USBManager, USBInterface, USBDevice etc.), but only by explicitly making a request for the report using a control transfer request.
I would like to be able to pull these input reports via interrupts on the appropriate endpoint. I have attempted to read packets from the first endpoint on the first interface (getInterface[0] and getEndpoint[0]) and I do receive data, but am having difficulty parsing the data in the byte buffer (I have the buffer set as little endian). In particular, how do I know the delimiters for each packet? I know each packet starts with a Sync field and that this Sync is 8bits and the last two bits indicate where the PID starts, but I am not sure exactly what that means. What are Ks and Js as many documents describe for the Sync and how are these represented as bits? Also, all packets are supposed to have an EOP, does this need to be parsed or is this handled by hardware?
Related
I have tried converting media into 'base64' string then tried to send it. But I think for more long string there will be problem to send that string via web sockets. Kindly share better idea for that.
There are 2 options to do the same,
Peer to peer file transfer:
This uses XMPP mechanism of P2P file transfer and is only suitable for when both users are online. We usually recommend using cloud stored file transfer (see below) unless you have concerns / limitations on server-side.
Cloud stored file transfer:
This uses QB Content API to store files when sent by the user and to retrieve them when other user(s) are ready to download them. The user experience is seamless and allows the user to send/receive files even when the other user is offline, the other user can open the conversation any time and download/play the file.
On client side, typically you want to handle things like progress bars, thumbnails for photos and videos etc.
I read this on Quora and it works
I have an old java program that is communicating with an embedded device manufactured in 2000. The program communicates with this device using the standard Windows serial stack (from what I can tell, when I capture data using PORTMON in windows I see requests like IRP_MJ_WRITE and IOCTL_SERIAL_SET_RTS).
The device however, connects to a serial port on the computer using a Serial-to-Stereo Plug connector, similar to this. I believe this means the device itself is only capable of sending signals using two pins.
How can I analyze raw communication between the two devices in an attempt to reverse engineer the protocol? I am on Windows, but am capable of moving to OS X or *unix. I know at some point I am going to have to write something to deal with the specifics of how the device communicates, but what do you guys recommend for gathering information?
The stereo jack is just a cheap way to implement a minimal RS-232-based connection. That shouldn't affect monitoring.
Portmon should display the data you need to investigate the protocol. The IRP_MJ_WRITE requests contain the data sent to the device, while the IRP_MJ_READ requests contain the data sent by the device.
If you cannot do this by software interception means, a simple multi-channel logic analyze (such as one of the FX2 USB designs) should be able to capture traffic on both the transmit and receive lines, and then allow you to software decode this at leisure to see the full interplay of transmissions, responses, and any delays in between.
I spent some time searching for a way to send data from a android application to Matlab - with no approach. I would prefer to do it with JSON via a Restful webservice.
I probably have the wrong concept in mind how this is going to work.
Matlab should be running/waiting for POST requests from my android device to receive the data, bring it into matlab form from json , progress it and send it back - than wait again for new requests.
The "RESTful web service" like "webread" seems not to wait for incoming data and go active for them.
How to let Matlab listen for incoming data with json ?
or how to let Matlab receive data from Android/java based programms ?
Do i need another frameworks, api's or even a server with Database to get that done ?
Can anyone give me some hints ?
Approach 1:
Matlab also provides Matlab Mobile https://de.mathworks.com/products/matlab-mobile.html, which is capable of executing Matlab code from your device, however, it is not possible to send images to Matlab.
However, you can use WebCam https://play.google.com/store/apps/details?id=com.pas.webcam&hl=en and open up a Server, which is pretty straightforward. You can run the app in the background and then connect to Matlab via Matlab-Mobile, and access it via your IP address and usually Port 8080.
Approach 2:
You can use a WebSocket -Server which is implemented here:
https://de.mathworks.com/matlabcentral/fileexchange/50040-jebej-matlabwebsocket
For more information on how to get it to run you can follow the directions given on the GitHub readme, here: https://github.com/jebej/MatlabWebSocket
A WebSocket Server is on the highest layer of the 7th layer (application layer) of the OSI model https://en.wikipedia.org/wiki/OSI_model and builds op on the 4th layer (TCP). However, you do not need to specify such things as buffer size etc.
The following example code is directly taken from the example code from the GitHub project. To fulfill the desired outcome in the Android application it is the best approach to rebuild the client application on Android.
Echo Server:
classdef EchoServer < WebSocketServer
%ECHOSERVER Summary of this class goes here
% Detailed explanation goes here
properties
end
methods
function obj = EchoServer(varargin)
%Constructor
obj#WebSocketServer(varargin{:});
end
end
methods (Access = protected)
function onOpen(obj,conn,message)
fprintf('%s\n',message)
end
function onTextMessage(obj,conn,message)
% This function sends an echo back to the client
conn.send(message); % Echo
end
function onBinaryMessage(obj,conn,bytearray)
% This function sends an echo back to the client
conn.send(bytearray); % Echo
end
function onError(obj,conn,message)
fprintf('%s\n',message)
end
function onClose(obj,conn,message)
fprintf('%s\n',message)
end
end
end
To run it in MATLAB type:
s = EchoServer(30000);
This will then utilize the port 30000 on your local machine.
On Android simply create a WebSocket-Client and use your URI, which you can find out by using ipconfig (windows) or ifconig (Linux). In Android the uri should like the following:
ws://192.168.1.102:30000
Where the IP address may change according to your IP address
Here are my 2 cents.
Your approach seems right.
Step 1: You need to run a web server using MATLAB on your device. By going through Web Server, it looks like you can use it to run webserver, and execute a .m file when a POST or GET request is made to your server.
Step 2: Lets say that your server is accepting requests on port 8080. From your Android device, if you are on same network then you can make a HTTP POST request to http://your.ip.address:8080 and extract the data and execute your code in .m file.
Note: You can also get a public URL for your local server running on the device using ngrok utility. Then make a POST request to that public URL. You need not be on the same network then in order to make a request. Here is some explanation: Accessing localhost from android over wifi.
Edit:
Additional question says:
Matlab is possible of receiving data via TCP/IP client, but how does the android site need to do the POST/GET algorithm and how can response Matlab responsible to it?
Let me rephrase what I understand. Firstly, you want to know how from Android code, one can do a POST/GET request and secondly how will Matlab respond to the request?
In Android you can make a POST request in background thread either using AsyncTask (Android HttpURLConnection with AsyncTask Tutorial) or if you want to do it properly, you can use Retrofit library to do POST/GET calls (Using Retrofit 2.x as REST client - Tutorial
).
When using WebServer as mentioned in the link previously, when the .m file gets executed on the POST call, you can send the response to the POST request from there. On Android, where you initiated the call, you can receive the callback.
Hope this helps a bit.
Have you tried the Android Support Package for MATLAB?
While it doesn't allow access to the camera, when used with MATLAB Mobile it does provide access to:
Acceleration on 3-axes
Magnetic field on 3-axes
Angular velocity on 3-axes
Azimuth, roll, pitch
Latitude, longitude, altitude, horizontal accuracy, speed, and course
Here's a link with more detailed information on how to get started.
I am trying to develop a Spring MVC based web application with following requirements.
User will swipe his/her magnetic strip or chip card on a card swiping machine.
The machine will read card information on card and will transport the same to my web application.
My questions are.
Is it possible to transport information from swipe machine on internet (Obviously the machine is connected to internet)
How do I configure the swipe machine to so it would transport information to my web application (should I expose a rest web service).
How do I decode the data which is transported by swipe machine in my Spring controller or web service
Thanks you very much for any help
Anant
Reading a mag strip (there are 3 of them in a card) is a simple job and you can rely on the driver that comes with the machine, or if you feel adventurous, break out the RxTx java library.
It is basically a bunch of letters and numbers - check wikipedia for the format of the CRC - but back to your questions:
Yes. Done that. Pretty simple. The machine has configurations that allow it to dial up or open a secure connection with a server.
Which number it will dial up or which service it will call is all configurable. Merchant will require you to provide your own machine and won't let you touch their existing machines.
Decoding is simple. The swiper comes with a driver and you can use it. However, if you have your own machine (which you will need) then decoding is not needed. The swiper will either call a server at the merchant (the case for restaurants or supermarkets) or it will open an HTTPS connection with the server and send all the data that it is in the card. Your server will get the data in plain text, so no need to read it manually.
Is it possible to transport information from swipe machine on internet (Obviously the machine is connected to internet)
The machine has to have output somewhere, where it does send data when doing something.
How do I configure the swipe machine to so it would transport information to my web application (should I expose a rest web service).
In documentation for machine, there should be info about what does it send and how. Everything else depends on this.
How do I decode the data which is transported by swipe machine in my Spring controller or web service
Same answer as for previous question.
I'm currently searching for a way to transfer a String array from one android to another through the internet (assuming both devices are connected to the internet).
There's the possibility that one (or both) of the devices is connected to a network which is provided by a router, therefore using the IP address isn't practical (as far as I know).
I've stumbled upon an idea which suggests using Email to transfer the data. but, if I'm not wrong, that will force me to translate the array to an Email, send it, and undo the translation (to get it back to a string array form).
I would prefer a solution that will transfer the String array as it is.
Is it possible? Is there a better way to executed this process?
(I'm developing in Java on the Eclipse IDE)
I'd be glad to hear your Ideas! (:
Several options:
Device A sends an HTTP Request to the web server, Device B regularly gets data( using timer ) by sending request to fetch message sent to him. But this is not really real-time.
Device A sends an HTTP Request to the web server, The Server Pushs to Device B. You need to implement Push using Comet or GWT.Comet wiki
Implement XMPP Messaging. Device A send an XMPP Request, Server push to Device B. XMPP wiki
If I were you, I will do no 3. Since your explanation sounds more related to real-time messaging case. Please forget thinking about using email.