我有一個錯誤,我不明白爲什麼會出現,最奇怪的是,有時會發生,但最近總是會發生,我使用的代碼是相同的,我沒有做任何更改,實際上我沒有執行任何代碼在應用程序的開始,我使用按鈕,所以我沒有得到這個錯誤的原因,請幫助我,錯誤是一個對話框說:Flash Builder 4.6原生擴展錯誤
本機擴展錯誤:有包裝錯誤/警告。檢查每個目標平臺的Flex Build Packaging Page中的每個本機擴展。你想繼續嗎?
,當我點擊是的程序不啓動,則debbuger告訴我的路線:
[SWF] SerialCOMGame.swf - 解壓後2121630個字節
,但從來沒有開始,我使用RS232庫串行通信,之前得到這個錯誤這項工作很好,但我不知道發生什麼事,我的C代碼:
/*
* NativeSerialComunication.c
*
* Created on: Jan 10, 2012
* Author: Diego Fernando
*/
#include "NativeSerialComunication.h"
int comport = 0;
int baudrate = 57600;
int buffsize = 4096;
unsigned char buffer[4096];
uint32_t comportOpened = 0;
FREObject IsSupported(FREContext ctx, void* functionData, uint32_t argc,
FREObject argv[]) {
FREObject result;
uint32_t isSuppoerted = 1;
FRENewObjectFromBool(isSuppoerted, &result);
return result;
}
int startCOMListener() {
if (!OpenComport(comport, baudrate)) {
comportOpened = 1;
return 1;
}
return 0;
}
void stopCOMListener() {
CloseComport(comport);
comportOpened = 0;
}
void COMListener(FREContext ctx) {
uint8_t compbytes = 0;
while (comportOpened) {
compbytes = PollComport(comport, buffer, buffsize);
FREDispatchStatusEventAsync(ctx, (const uint8_t *) "listening for data",(const uint8_t *)"datalistening");
if (compbytes) {
FREDispatchStatusEventAsync(ctx, (const uint8_t *) buffer,
(const uint8_t *) "datareceived");
}
Sleep(100);
}
}
FREObject startSerialListener(FREContext ctx, void* functionData, uint32_t argc,
FREObject argv[]) {
FREObject result;
if (startCOMListener()) {
CreateThread((LPSECURITY_ATTRIBUTES) NULL, 0,(LPTHREAD_START_ROUTINE) COMListener, ctx, 0, NULL);
FREDispatchStatusEventAsync(ctx, (const uint8_t *) "listener started",
(const uint8_t *) "listenerstarted");
}
FRENewObjectFromBool(comportOpened, &result);
return result;
}
FREObject stopSerialListener(FREContext ctx, void* functionData, uint32_t argc,
FREObject argv[]) {
FREObject result;
stopCOMListener();
FRENewObjectFromBool(comportOpened, &result);
return result;
}
FREObject sendDataToSerialPort(FREContext ctx, void* functionData,
uint32_t argc, FREObject argv[]) {
FREObject result;
uint32_t dataSended = 0;
uint32_t dataToSend = 0;
FREGetObjectAsUint32(argv[0],&dataToSend);
printf("data to be sended %d",dataToSend);
if (comportOpened && !SendByte(comport,dataToSend)) {
dataSended = 1;
}
FRENewObjectFromBool(dataSended, &result);
return result;
}
void MyContextInitializer(void* extData, const uint8_t* ctxType, FREContext ctx,
uint32_t* numFunctionsToSet, const FRENamedFunction** functionsToSet) {
*numFunctionsToSet = 4;
FRENamedFunction* func = (FRENamedFunction*) malloc(
sizeof(FRENamedFunction) * 4);
func[0].name = (const uint8_t*) "isSupported";
func[0].functionData = 0;
func[0].function = &IsSupported;
func[1].name = (const uint8_t*) "sendDataToSerialPort";
func[1].functionData = 0;
func[1].function = &sendDataToSerialPort;
func[2].name = (const uint8_t*) "startSerialListener";
func[2].functionData = 0;
func[2].function = &startSerialListener;
func[3].name = (const uint8_t*) "stopSerialListener";
func[3].functionData = 0;
func[3].function = &stopSerialListener;
/*func[1].name = (const uint8_t*) "sayHelloWorld";
func[1].functionData = 0;
func[1].function = &sayHelloWorld;*/
*functionsToSet = func;
}
void MyContextFinalizer(FREContext ctx) {
return;
}
void initializer(void** extDataToSet,
FREContextInitializer* ctxInitializerToSet,
FREContextFinalizer* ctxFinalizerToSet) {
extDataToSet = 0; // This example does not use any extension data.
*ctxInitializerToSet = &MyContextInitializer;
*ctxFinalizerToSet = &MyContextFinalizer;
}
void finalizer(void** extDataToSet) {
stopCOMListener();
return;
}
這是使用原生的C代碼我ActionScript代碼:
package com.nativeserialcomunication.driver
{
import flash.events.EventDispatcher;
import flash.events.IEventDispatcher;
import flash.events.StatusEvent;
import flash.external.ExtensionContext;
public class NativeSerialComunication extends EventDispatcher
{
private var extensionContext:ExtensionContext;
private var isSerialListenerStarted:Boolean = false;
public function NativeSerialComunication(target:IEventDispatcher=null)
{
super(target);
extensionContext =ExtensionContext.createExtensionContext("com.nativeserialcomunitacion.driver.NativeSerialComunitation","");
extensionContext.addEventListener(StatusEvent.STATUS,statusHandle);
}
public function init():void{
if(extensionContext.call("startSerialListener") as Boolean){
isSerialListenerStarted = true;
trace("serial listener started");
}
else{
trace("no serial listener started");
}
}
public function statusHandle(event:StatusEvent):void{
trace("the event ("+event.level+") received, data:"+event.code);
}
public function isSupported():Boolean{
return extensionContext.call("isSupported") as Boolean;
}
public function sendDataToSerialPort(data:uint):Boolean{
return extensionContext.call("sendDataToSerialPort",data) as Boolean;
}
}
}
我喜歡這個...一直在使用ArduinoConnector(http://code.google.com/p/as3-arduino-connector/wiki/Introduction)進行直接串行通信,但它有一些與崩潰一定條件下。 diego,你是否得到了這個直接連續ANE的工作?你能把它提供給其他人嗎?謝謝! – ericsoco 2012-03-09 23:11:18