moe85 / as3-arduino-connector

Automatically exported from code.google.com/p/as3-arduino-connector
0 stars 0 forks source link

Stop Responding after about 5 seconds #8

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Windows 7 home premium 
2. Connect to serial source
3. Poll device with data in an interval base
4. After some time it dies.

Same code works in mac osx  without any issue

What is the expected output? What do you see instead?

AS3 calls INVENTORY function every second.
UART always reply to message.

trace output:

INVENTORY -> sends:05000100ae74
OK:04000e2cb3
INVENTORY -> sends:05000100ae74
OK:04000e2cb3
INVENTORY -> sends:05000100ae74
OK:04000e2cb3
INVENTORY -> sends:05000100ae74
INVENTORY -> sends:05000100ae74
INVENTORY -> sends:05000100ae74
INVENTORY -> sends:05000100ae74
INVENTORY -> sends:05000100ae74

What version of the product are you using? On what operating system?

version 1.0.0
Windows 7 home premium on both virtual and native shows the same issue

Please provide any additional information below.

Code:

RFID = new ArduinoConnector();
RFID.addEventListener(Event.ACTIVATE, onConnected);
RFID.addEventListener("socketData", onRFIDData);
RFID.connect("COM3",19200);

function onConnected(event:Event):void{
   var x:Timer = new Timer(1000,1);
   x.addEventListener(TimerEvent.TIMER_COMPLETE, function():void{
      inventory();
   });
   x.start();
}

function onRFIDData(event:ArduinoConnectorEvent):void{
   var str:String = "";
   var data:Array = RFID.readBytesAsArray();
   for(var i:Number = 0 ; i < data.length ; i++)
      data[i] = data[i].charCodeAt(0);
   trace(data);
}

Original issue reported on code.google.com by mirza.ce...@gmail.com on 15 Jan 2012 at 8:47

GoogleCodeExporter commented 9 years ago
Unable to reproduce.  May be related to Issue 12, but unsure.  May need to do a 
hardware debug.

Original comment by Nicholas...@gmail.com on 25 Mar 2012 at 3:51

GoogleCodeExporter commented 9 years ago
you can try adding 
else if(sentEvent==1)
      {
          multiplatformSleep(500);
          sentEvent=0;
      }
after
 if ((sentEvent == 0) && (((prevCollection == 0) && (bufferSize > 0)) || (bufferSize > 1024)))
        {
          FREDispatchStatusEventAsync(dllContext, (uint8_t*) "bufferHasData", (const uint8_t*) "INFO");
          sentEvent = 1;
        }
it clears the data automatically if the flag sentEvent is set. 
If sentEvent is set to true, but for some reason you didn't get the event (and 
thus the appliaction is unable to read from the buffer, because it doesn't 
know, that there is any data), you won't receive any more events (because they 
only fire if sentEvent is set).

Original comment by memel...@gmail.com on 16 May 2012 at 9:29

GoogleCodeExporter commented 9 years ago
Having the same problem, but I don't see where that code goes. I assume I would 
need the source code to make that change?

Thx,
Les

Original comment by mastafla...@gmail.com on 17 May 2012 at 10:55

GoogleCodeExporter commented 9 years ago
yep, here is the original source:
http://code.google.com/p/as3-arduino-connector/source/browse/trunk/native-extens
ion/Windows-x86/SerialANE.c

Original comment by memel...@gmail.com on 18 May 2012 at 7:49

GoogleCodeExporter commented 9 years ago
Similar problem here, under windows and mac though much more likely to happen 
on windows. my arduino just does serial.println (5_character_string) every 
500ms or so, after an indeterminate though short (normally from 5 seconds to a 
minute) the socketData event stops firing, though I can see from the LED on my 
usb/ttl converter that data is still being sent, and if I reconnect to 
as3-arduino-connector the data is then received again (up until the next 
failure).
No errors are raised - I can work around this for the moment by reconnecting if 
data is not received for a few seconds. 
Any ideas/advice welcomed.

Original comment by hayes....@gmail.com on 18 May 2012 at 2:51

GoogleCodeExporter commented 9 years ago
Description Resource    Path    Location    Type
undefined reference to `__imp__pthread_cancel'  SerialANE.c /ArduinoConnector    
    C/C++ Problem
undefined reference to `__imp__pthread_create'  SerialANE.c /ArduinoConnector    
    C/C++ Problem
undefined reference to 
`__imp__pthread_mutex_lock' SerialANE.c /ArduinoConnector       C/C++ Problem
undefined reference to 
`__imp__pthread_mutex_unlock'   SerialANE.c /ArduinoConnector       C/C++ Problem

windows 7 64 bit, flash builder 4.6, flex sdk 4.6, air sdk 3.3, CDT+MinGW

Original comment by slongs...@gmail.com on 8 Jul 2012 at 8:24

GoogleCodeExporter commented 9 years ago
Same issue happens. This functionality is very important in my opinion. 
Providing more reliable data exchange in both directions would made serial 
connector just brilliant!
Are there any plans to publish ANE update?

Original comment by xaci...@gmail.com on 17 Sep 2012 at 9:55

GoogleCodeExporter commented 9 years ago
Testing on Windows XP, confirm the problem. 
Are being correctly written to the port, no data to read detected. More often 
it happens, when the data block to process is bigger thean usual 30-50 bytes. 

Has anybody scanned the sources for defect of that kind?

Original comment by xaci...@gmail.com on 24 Sep 2012 at 2:23

GoogleCodeExporter commented 9 years ago
same issue here: win 7 64-bit

my arduino has an endlessloop than continously sends something to serialport to 
my program and also receives something from it: after some time this stops 
working -> For me it seems to be after the second time i send something  to 
arduino.

Here is a more detailed description:

1. arduino continually sends something in an endlessloop
2. i send something to arduino
3. arduino still sends something in an endlessloop
4. i send something to arduino again
5. arduino doesn't send anything in an endlessloop anymmore (as it should!)

So the problem is: There are no more ArduinoConnectorEvents fired after the 
second "send" from client to arduino. It seems to me it's a problem with 
bidirectional communication.

Would be great if this issue could be resolved in the next version! Thanks in 
advance!

Original comment by gernotfe...@gmail.com on 12 Nov 2012 at 8:42

GoogleCodeExporter commented 9 years ago
I had to stop using this ane because of this afraid.

Original comment by andytwo...@gmail.com on 12 Nov 2012 at 9:21

GoogleCodeExporter commented 9 years ago
Had anyone found any better ANE? I'm thinking of forking the project, naming it 
"as3-serial-connector"

Original comment by xaci...@gmail.com on 12 Nov 2012 at 9:38

GoogleCodeExporter commented 9 years ago
Sorry about the long delays guys.  I've been out on other projects that didn't 
really relate to this, so I didn't get a chance to spend much time with this.

I am now able to reproduce it.  I think I have a fix, but I haven't written it 
yet.  Additionally, I have some other patches that people have submitted that 
will help with some other things people have pointed out (allowing you to 
connect to multiple serial ports at the same time).

That being said, if anybody wants to take a stab at it, I will be more than 
happy to give committer rights.  Or if you email me a patch I will merge it in 
and make an updated version.  I have a pretty extensive test suite setup now 
that also catches this bug (it didn't catch it before, but it's pretty good at 
catching others).

Original comment by Nicholas...@gmail.com on 12 Nov 2012 at 11:13

GoogleCodeExporter commented 9 years ago
If somebody could check out this patched file to see if it fixes the issue.  
This would be for Windows.  You will need to open up the ANE file (it is a zip 
file), and replace this DLL.  If it does fix it, I will repackage the ANE to 
include the fix for Mac along with some of the other bug fixes I've found over 
the last month.  

Original comment by Nicholas...@gmail.com on 13 Nov 2012 at 2:45

Attachments:

GoogleCodeExporter commented 9 years ago
Thank you very much!!!

At least for me it fixes the issue!

Original comment by gernotfe...@gmail.com on 13 Nov 2012 at 8:43

GoogleCodeExporter commented 9 years ago
Will try tomorrow morning and let you know :)
cannot wait for the mac version as well, it have been stable for a bit longer, 
but eventually stops too.

Regards

Mirza Ceyzar

Original comment by mirza.ce...@gmail.com on 14 Nov 2012 at 2:05

GoogleCodeExporter commented 9 years ago
Hi, sorry for taking so long to reply, 
anyway here is my findings:

with original DLL : Fails after 5 calls
with the new DLL : Fails after about 120 calls

here is the code for flash builder:
------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                       xmlns:s="library://ns.adobe.com/flex/spark" 
                       xmlns:mx="library://ns.adobe.com/flex/mx" applicationComplete="onInit();">
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <fx:Script>
        <![CDATA[
            import com.quetwo.Arduino.ArduinoConnector;
            import com.quetwo.Arduino.ArduinoConnectorEvent;

            private var i:int = 0;

            private var arduino:ArduinoConnector = new ArduinoConnector();

            private function onInit():void{
                arduino = new ArduinoConnector();
                arduino.addEventListener(Event.ACTIVATE, onConnected);
                arduino.addEventListener("socketData", onRFIDData);
                arduino.connect("COM7",9600);
            }
            private function onConnected(event:Event):void{
                var x:Timer = new Timer(100,0);
                x.addEventListener(TimerEvent.TIMER, function():void{
                    arduino.writeString("Hello");
                    arduino.flush();
                });
                x.start();
            }
            private function onRFIDData(event:ArduinoConnectorEvent):void{
                ta.appendText("\n" + (i++) + ":" +arduino.readBytesAsString());
            }

        ]]>
    </fx:Script>
    <s:TextArea id="ta" left="0" right="0" top="0" bottom="0"/>
</s:WindowedApplication>
------------------------------------------

here is the code for the arduino/PIC:
------------------------------------------
void main() {
   while (1) {
    if (UART1_Data_Ready()) {
      UART1_Write(UART1_Read();
    }
  }
}
------------------------------------------

the pic is working perfectly as when i close the air and reopen it resumes 
where it left off. And also i tried with UART terminal from mikroC application 
and left it overnight still works in the morning.

but the ArduinoConnector fails under 5 seconds with the old DLL and with the 
new DLL fails under 40 seconds with 100ms read/write interval.

I hope this helps.

Original comment by mirza.ce...@gmail.com on 18 Nov 2012 at 7:46

GoogleCodeExporter commented 9 years ago
Same problem. My arduino send an endless stream. After few seconds the 
extension stops working. Tried with several computers all with Windows x64

Original comment by lisoph...@gmail.com on 8 Dec 2012 at 5:04

GoogleCodeExporter commented 9 years ago
Hi dudes, Help me out of the issue i am facing,

After call the dispose and close methods, When i un-plug the device and plug it 
again,application goes hang state.

Message shows "[ArduinoConnector] Initalizing ANE...". after that application 
hangs.

Note:- I called the ardunio methods correctly, it executes perfect till the 
device un-plugged and plugged after that the above things happenings.

Original comment by beeraham...@gmail.com on 23 Jan 2013 at 1:10

GoogleCodeExporter commented 9 years ago
Hurray!!! Hope, Our team got solution. Found the Hang state(end less loop).
Go to SerialANE.c file and change the code, declare one variable after "int 
sentEvent"; we did like "int dispose;" initialize as dispose=0 in "setupPort" 
function() and make it dispose=1 in "closePort" function(). The main problem 
occurs on "pollForData()" it is going end less loop, so have to control this. 
we write a code while(dispose==0) instead of while(1) then see the magic. Hope 
so, endless stream comes to end.

Original comment by beeraham...@gmail.com on 28 Jan 2013 at 1:32

GoogleCodeExporter commented 9 years ago
@ beeraham...

Can you supply the fixed dll? I tried to incorporate your changes in the 
downloaded trunk from Arduino Connector, but can't get it to compile as 
DLL...getting some dependecy and "unknown resource" errors in Eclipse/FB with 
pthread. Although the .dll and/or the .h files are linked.

It would be cool, but if you can't cause it was a paid project and the customer 
won't allow such handling of files, it's also OK.

Just wanted to ask before I gotta switch from the totally cool AC to the old 
serproxy method for a project.

Thanks very much, Leo

Original comment by bergmann...@gmail.com on 22 Feb 2013 at 6:53

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
If anybody has a working solution for the problem, please commit it or do the 
fork, put the link here.

The requested feauture is terribly nedeed!

Original comment by xaci...@gmail.com on 25 Feb 2013 at 10:24

GoogleCodeExporter commented 9 years ago
Add these *.dll files and make the .ane file then check it.Hope, It may solve 
the hanging issue.

Original comment by beeraham...@gmail.com on 4 Mar 2013 at 6:33

Attachments:

GoogleCodeExporter commented 9 years ago
@ beeraham...

Thank you for supplying these dlls. I hope I get the chance to check them out 
this week. Will report as soon as I got the chance to.

Cheers!

Original comment by bergmann...@gmail.com on 12 Mar 2013 at 5:01

GoogleCodeExporter commented 9 years ago
@beeraham

I implemented your files into my ANE but now I recieve this error

VerifyError: Error #1014: Class com.quetwo.Arduino::ArduinoConnector could not 
be found.

Before this I was using the latest update by Nicholas in 12 Nov and was facing 
the same problem as beeraham with reconnecting to the device. Thanks

Original comment by prakashg...@googlemail.com on 8 Apr 2013 at 3:41

GoogleCodeExporter commented 9 years ago
Now I finally got the time to get back to my project which I'd like to use 
ArduinoConnector for. 

I added the .dlls to my .ane and linked it the compiler of Flash. While 
compiling I get this error message, maybe someone can find a solution for this 
problem:

/*
ArgumentError: Error #3500: The extension context does not have a method with 
the name setupPort.
    at flash.external::ExtensionContext/_call()
    at flash.external::ExtensionContext/call()
    at com.quetwo.Arduino::ArduinoConnector/connect()[C:\Users\Nicholas Kwiatkowski\Adobe Flash Builder 4.6\SerialANELib\src\com\quetwo\Arduino\ArduinoConnector.as:83]
...

*/

Thanks a lot, Leo

Original comment by bergmann...@gmail.com on 17 Apr 2013 at 12:48

GoogleCodeExporter commented 9 years ago
OK, I got the .ane to work with the supplied .dlls. Thanks a lot, beeraham!
I also had some time for further testing. With the original and the new .ane.

I've also tried two differend Arduino Unos out. And now it get's interessting:

I get the disconnect rather frequent when I use my normal Arduino Uno, an 
Arduino Uno SMD. When I use an Arduino Uno Rev 3 with the big replacable chip I 
can't provoke the disconnect. Rather strange, isn't it?

Has anyone the possibility to try the same? Or what kind of boards are you 
using?

Cheerswell everyone, Leo

Original comment by bergmann...@gmail.com on 19 Apr 2013 at 3:06

GoogleCodeExporter commented 9 years ago
This should be fixed with version 1.5.0.

The "hanging" issue that beerahamedkhan included will be fixed in 2.0.  I am 
re-writing some of the code to allow for multiple devices to be used at once -- 
the re-write will fix that issue.

Original comment by Nicholas...@gmail.com on 23 Apr 2013 at 3:41

GoogleCodeExporter commented 9 years ago
Was that also fixed for Mac OS X? I'm experiencing the same problem. (It's 
stuck at "OpenComport")

Original comment by madtrac...@gmail.com on 30 Apr 2014 at 8:31

GoogleCodeExporter commented 9 years ago
Hi Everyone, I got the same error as Leo #26
/*
ArgumentError: Error #3500: The extension context does not have a method with 
the name setupPort.
    at flash.external::ExtensionContext/_call()
    at flash.external::ExtensionContext/call()
    at com.quetwo.Arduino::ArduinoConnector/connect()[C:\Users\Nicholas Kwiatkowski\Adobe Flash Builder 4.6\SerialANELib\src\com\quetwo\Arduino\ArduinoConnector.as:83]
...

*/
Has anyone already found a fix?
Thanks

Original comment by absolout...@gmail.com on 14 Dec 2014 at 9:54