I have a mistake that I don’t understand why it appears, the strangest thing is that it happens sometimes, but lately always, the code that I use is the same and I do not make any changes to it, in fact I do not execute no code at the beginning of the application, I use buttons, so I have no reason with this error, please help me, the error is a dialog that says:
Internal extension Error: there are errors / warnings about packaging. Check each internal extension on the Flex Build build page for each target platform. would you like to continue?
And when I click yes, the program does not start, debbuger shows me the line:
[SWF] SerialCOMGame.swf - 2,121,630 bytes after decompression
but it never starts, I use the RS232 library for serial communication, before I get this error, this work is fine, but I don’t know what will happen, my C code:
#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;
*functionsToSet = func;
}
void MyContextFinalizer(FREContext ctx) {
return;
}
void initializer(void** extDataToSet,
FREContextInitializer* ctxInitializerToSet,
FREContextFinalizer* ctxFinalizerToSet) {
extDataToSet = 0;
*ctxInitializerToSet = &MyContextInitializer;
*ctxFinalizerToSet = &MyContextFinalizer;
}
void finalizer(void** extDataToSet) {
stopCOMListener();
return;
}
And this is my ActionScript code that uses native C code:
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;
}
}
}