Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-15-2006, 07:23 PM
Junior Member
 
Join Date: Feb 2006
Posts: 12
Default Serial Comm - saving incoming stream

hi

my program is working fine,
basically the code and everything is unchanged from the sample
program QM that is available on the website.

Now I want to save a stream of incoming text response from com port.
I have a micro controller attached to the com port,
I send it a chck command and it reponds with a stream of text for e.g
"AH BH CH DH EH FH GH HH"
I want to be able to capture this whole string so I can further write code in flash to process this information.

> on a side note / although the qm program works, but in the response text box I cannot see the text properly /complete.

For e.g. original response is AMOUNT OF T: 04
in the reponse textbox i can only read "T:04"
this is not issue of textbox being too small to handle the whole text...

//another side note: In Qm sample program is there specific Baudrate being used ? / if so what is it / I want to have a baudrate of 9600.

thanks..
waiting for reply.
- sz
Reply With Quote
  #2 (permalink)  
Old 03-16-2006, 05:00 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:Serial Comm - saving incoming stream

There is a baudrate property of the cportx component, so you can use it to change the baudrate.

About the lost message, could you please send us your code of receiving com port messages? We will try to find out the reason.
Reply With Quote
  #3 (permalink)  
Old 03-17-2006, 03:36 PM
Junior Member
 
Join Date: Feb 2006
Posts: 12
Default Re:Serial Comm - saving incoming stream

Hi
I am at the university right now otherwise I would send it.

But here is the thing...
The code I am using is EXACTLY the same as QM.fla sample file.

I downloaded the sample file and only removed the input text box and replaced it with buttons that basically define the input and also have the 'Query modem button' code on it.

So for example I have a button.
When i press the first button it says sumthing like command = "watever i want to send"
and other code is same as QM file sample from website.

Also about the property of cportx for baudrate...
if you could pin point that out where it is again in the Qm sample code....
like it is called 'baud_rate" etc or it appears within some commands parameters
samplecommand (xx,xx,baudrate here) etc.

and/or please tell me the default baud rate that the qm is using. so i might search in code
and change it to my desired one.

I will go home and use the qm.exe again and see if I can actually see the text properly in the sample program or not and get back to you on that.

thanks
- SZ


ALso in relation to this software I also posted this in a new thread.

================
i hv a software that uses the cportx active x component.
Once I have made my application and run it on a new computer it
says please install active x cport first.

I want to put it inside my application somehow so I do not have
to install it.

I cannot even install cportx on uni computers because of having no admin rights.
does embedding activex help with that.

I saw import activex tab on the swfkit software..but i am not sure which files to import etc.

Example/Sample skp project file with cportx embedding would be very koooooooool
--------------

thanks for the support

SZ
Reply With Quote
  #4 (permalink)  
Old 03-18-2006, 12:27 AM
Junior Member
 
Join Date: Feb 2006
Posts: 12
Default Re:Serial Comm - saving incoming stream

hi

i found out the problem which was causing the response box to only show come responses and not others.
I made the text box very big and noticed that after the first reponse there are two line(vertical) spaces...and then all the rest appear at the same 3rd line. And that happens everytime the command to the microcontroller changes....

so i guess it is issue on the port of psoc that it is hitting carriage returns ?

neway so now the question is how to write code about a particular part of the code.
for example the reponse is AH BH CH DH EH FH GH HH
AH appears then BH appears on same line then CH and so on.

I need to write code to check if the reponse is AH or AL in actionscript.
so if i can save the particular reponse in a string i know how to do the if loops etc.
question how to get the reponse in a string.

This reponse is received when a particular button is pressed so I can put some code in button to start capture stream etc if required....about when to stop capture i do not know what is convenient a can easily gave string a length and say just save the first 20 characters etc.

also still curious about the baudrate...
it is working fine with the microcontroller so i dont hv issue here i am just amazed that
the microcontroller has 9600 baudrate and i am unable to use it with hyperlink unless I put 9600 as speed. is it a coincidence that QM sample program also has same or is it find the baudrate some how.

thanks
SZ


Reply With Quote
  #5 (permalink)  
Old 03-21-2006, 12:53 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:Serial Comm - saving incoming stream

1. check the response
Code:
commx.onRxChar = function (count)
{
var stream = this.read(count);
var str = stream.read(2);
if (str == 'AH') 
{
...
}
else if (str == 'AL')
{
...
}
}
2.change the baudrate

Code:
commx.baudrate = 14400;
trace(commx.baudrate);
Reply With Quote
  #6 (permalink)  
Old 03-22-2006, 07:15 AM
Junior Member
 
Join Date: Feb 2006
Posts: 12
Default Re:Serial Comm - saving incoming stream

hi

tried to get it to work...no luck yet...

i presume " commx.onRxChar " is a command/function and should be used exactly as it is. Or is commx a variable that could have been defined as something else in the sample program QM.

I do not know where to place the code.
Here is what I am trying I open the sample qm.fla from website/
add a new layer and add the code on the first frame as.

Code:
commx.onRxChar = function (count)
{   
   var stream = this.read(count);
   var str = stream.read(2);
   if (str == 'AH') 
   {
      ans = "Yes";
   }
   else if (str == 'AL')
   {
      ans = "NO";
   }
}
Then on the screen i placed a dynamic text box which has the variable set as 'ans'.

Does not work...

Please tell me exactly where to put this code in the sample qm.fla file.
is commx <-- supposed to be used as it is or could it have been called something
different in the sample qm.fla program.

I also tried to change the variable from 'ans' to _root.ans , still no results.

ALso tried the baudrate command just to mess it up to something unsable, but seems the baudrate is also not being changed as microcontroller still works. (it shld not work
for all baudrate , only for 9600). Again i am putting the code in a new layer/first frame in sample qm.fla program.

thanks for your patience...
I am almost there this is the last functionality I need for this project....

I might want to load jpgs but I have seen that issue being addressed a number of times on the forum so i will use those to figure it out if/when i run into problems.

thanks again
SZ



Reply With Quote
  #7 (permalink)  
Old 03-22-2006, 01:02 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:Serial Comm - saving incoming stream

The code must be added into one of your ffish scripts, the "initialize" script would be ok.

"commx" is an instance of the CPortX ActiveX Component, which is created in ffish script:

Code:
commx = new ActiveXObject("CPortX.ComPortX");
And "onRXChar" is an event of the CPortX object. Whenever the cportx obejct receives charactors from the specified port, it calls the event handler so that you can read the received charactors in the event handler. So you can put the event handler in the "initialize" script just after you create the instance of the cportx.
Reply With Quote
  #8 (permalink)  
Old 03-22-2006, 07:15 PM
Junior Member
 
Join Date: Feb 2006
Posts: 12
Default Re:Serial Comm - saving incoming stream

thanks alotttttttttt

got it to work

you rockkk
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 03:35 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.