Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - SerialStream usage

SerialStream usage

Discuss OrbForms Designer and PocketC Architect

Postby lazarus on Thu Aug 11, 2005 4:58 am

I am trying to use the SerialStream object for serial port data acquisition. My test setup includes a PDA and a computer. I can write from the PDA to the computer, but I have not been able to receive any data from the computer back to the PDA. I ran a separate serial app to verify the computer was sending information.
My code looks as follows:

// Create the serial port object.
Serial oSerial;
SerialStream serStream;

// mainform.oc
// Created for mainForm

handler mainForm.onopen() {
// Use the timer to repeat the polling cycle.
oSerial.open(serCradlePort,9600);
oSerial.settings(8,1,0,"n",1);
serStream.serial = oSerial;

// Start the forms timer handler.
timer(1);
}

handler mainForm.ontimer() {
string strIO;

// Write to the serial stream.
serStream.writeString("spstat");

// Repeat every 2 seconds.
sleep (2000);

// Read from the serial stream.
serStream.readString(&strIO);

// Update the field.
fldSerialInput.text = strIO;

timer(1);

// Reset the auto off timer.
resetaot();
}

One other hint. I displayed the result from the serStream, and it always returned 0, or false indicating some sort of error. Has anybody tried using the SerialStream with success? Thanks.
lazarus
 
Posts: 8
Joined: Sun Jul 24, 2005 9:23 pm

Postby lazarus on Sun Aug 14, 2005 11:46 pm

Here is a workaround for using the SerialStream object. I never could get the "readString" function to work. However, the "read" function did work, with just a little extra work.

handler mainForm.ontimer() {
char c[512];
char* pc;

pc = c;

// Read from the serial stream. The default serial object buffer size is 512 bytes.
serStream.read(pc,typeof(*pc),512);
fldSerialInput.text = strctos(pc);

// Repeat every 2 seconds.
timer(200);

// Write to the serial stream.
serStream.writeString("spstat\n\r");

// Reset the auto off timer.
resetaot();
}

I switched from the "sleep" to the "timer" function to prevent unwanted "hang ups". Also note that I correctly set the nticks value in the "timer" function this time (1 tick = 1/100 sec.). If anyone uses the "readString" function with a string type variable, please post it so I can see what I was doing wrong.
lazarus
 
Posts: 8
Joined: Sun Jul 24, 2005 9:23 pm

Postby dewey on Wed Aug 17, 2005 3:49 am

Stream.readString() reads until it gets a NULL character, not end-of-line. So, it was probably timing out.
dewey
Site Admin
 
Posts: 749
Joined: Sun Oct 21, 2007 5:12 am

Postby md10bldr on Tue Aug 30, 2005 7:25 pm

So I've messed with the serStream.readString and serStream.writeString commands, and can get my PC(with Palm emulator) to send and receive serial data to/from an external PPC. I do have a couple of questions though.
1.) The example code above is basically polling the serial port. I've searched through the help file, but haven't seen anything that would indicate that receipt of serial data (Comm, BT, or IR) triggers any kind of system event that would go to an event handler. Is this true?

2.) The addition of the (null) to the end of a string when using "readstring" - As a relatively inexperienced programmer, is this something I'm suppose to know (something associated with the use of streams)? Since there's nothing in the help file, I doubt I would have ever gotten this working without the forum. How many more things like this are there?
md10bldr
 
Posts: 17
Joined: Wed Dec 04, 2002 6:55 pm


Return to OrbForms Designer and PocketC Architect

Who is online

Users browsing this forum: No registered users and 3 guests

cron