问题
I am not clear where my trouble is stemming as I believe all things are set up properly, yet my Flash app STILL can not make a connection to 'SOCAT' to read the incomigng serial data from a connected Arduino.
Project Summary:
Adobe Flash app
- Written in ActionScript 2 (AS2.0)
- This does have a camera object in it, (but that seems to be working just fine, and is not a focal point here)
RPi 3B Rev.2
- LAMP installed (Apache, MySQL, PHP and MyPHPAdmin as well)
Running a SOCAT instance upon boot, using this line:
socat -d -d -d -d -x TCP-LISTEN:7777,reuseaddr,fork FILE:/dev/ttyUSB0,b9600,raw
Arduino connected to RPi via USB cable (ie: ttyUSB0 it enumerates as)
- Arduino - runs temp sketch that sends serial data every second or so (string of :'data' being sent over & over)
I have verified that BOTH the incoming Arduino data is being sent (via Arduino IDE to check the board itself, as well as) using an instance of PUTTY on the RPI to make a connection and check on data being sent on the ttyUSB0 line.. and also received on the 127.0.0.1:7777 port)
Arduino:
SOCAT/RPi:
When I open either of these windows.. I see:
data
data
data
data
Which is what the Arduino is sending.
So at this point..
I have a the data being sent properly. I have the data being received properly. (at least up to the SOCAT level)
However.. I can NOT (for the life of me) get my Adobe Flash App to connect to this SOCAT instance and read this incoming data from the USB connected Arduino!!!
I started to read up on this.. and read about the security policy that the Flash Player needs to allows this connection.
So after some messing about, I finally got the following set-up and working correctly (I believe at least, but if it was all perfect, I wouldnt be here.. right?) :)
I set up SSL with a self-signed certificate. I (eventually) got a security policy server set up, using an Apache mod (designed for just this scenario)
And when I run this line:
perl -e 'printf "<policy-file-request/>%c",0' | nc 127.0.01 843
I get the policy reference returned to me:
<?xml version='1.0'?>
<!DOCTYPE cross-domain-policy SYSTEM
'http://www.adobe.com/xml/dtds/cross-domain-policy.dtd'>
<cross-domain-policy>
<site-control permitted-cross-domain-policies='all'/>
<allow-access-from domain='*' secure='false'/>
<allow-http-request-headers-from domain='*' headers='*' secure='false'/>
</cross-domain-policy>
I have even gotten my custom one to load (which is really just the same config, but wanted to see if the 'master' file was allowing for custom policies, and it was/is)
Maybe the fault is on the Flash/AS side of things? Here is how I am attempting to make the XMLSocket connection with the running SOCAT instance:
import flash.system.Security;
Security.allowDomain("*");
Security.allowInsecureDomain("127.0.0.1");
Security.loadPolicyFile("xmlsocket://127.0.0.1:843");
//instantiate instance
var rpi_usb0_Listener = new XMLSocket();
//create listeners:
//on connect
rpi_usb0_Listener.onConnect = function(result){
if(result){
//connected
state_txt.text = "on-connect success";
}else{
//not connected
state_txt.text = "on-connect failed";
}
}
//on close
rpi_usb0_Listener.onClose = function(){
//disconnected
state_txt.text = "connection closed";
}
//on incoming date recieved
rpi_usb0_Listener.onXML = function(data){
//do whatever
incomingData_txt.text += data;
//close
//rpi_usb0_Listener.close();
}
//make connection
if(!rpi_usb0_Listener.connect(null, 7777)){
state_txt.text = "connection true";
}else{
state_txt.text = "connection false";
}
No matter I have tried.. I can never connect.
I get "on-connect failed" on the screen every time.. (after 15 second timeout)
I need the help of someone more knowledgeable in this area than me it seems, as I cant seem to make a connection to save my life.
If there is some more info I can provide, please ask.. If there is some log file I should check out to get a better handle on what is going on.. (please let me know)
Is it my SOCAT line/setup? That is not allowing the connection from my Flash app?
来源:https://stackoverflow.com/questions/54974902/adobe-flash-app-to-read-from-socat-instance-on-raspberry-pi