Thursday, August 2, 2007

[oopic] Re: Converting a string value to a numeric value?

--- In oopic@yahoogroups.com, "thetruth_as_i_seeit" <lone_wolf@...> wrote:
>
> I'm trying to receive data to my OOPic R through a serial port
> connected to a laptop. I want to use this data to control objects
> from the OOPic but, in order to do that, I need to convert the string
> data that is coming from the serial port to numeric data.
>
> In C, there is a specific function for this called atoi, but I can't
> find anything like it in the OOPic manual.
>
> Just in case anybody wants to see it, here is my code ...
>
> Dim A As New oDIO1
> Dim B as New oSerial
>
> Sub Main()
> A.IOLine = 8
> A.Direction = cvOutput
> B.Baud = cv9600
> B.Operate = cvTrue
> A = 0
> Do
> If B.Received = cvTrue then
> B.Value = B.value
> End If
> A = B
> Loop
> End Sub
>
> Obviously, this doesn't work because B is not a zero or one in a
> numerical sense, and what I am picking up is ASCI code ... in other
> words a whole bunch of zeros and ones.
>
> Any thoughts?
>

Two thoughts: you REALLY want to use oSerialPort instead of oSerial.
This will give you a 4 byte receive buffer that you WILL need.

Second, you should plan to use SCP (chapter 16 of manual) for a couple
of reasons: First, it is pretty flexible in allowing you to change the
properties of objects and second because it OOPic can process the data
much faster internally than you can with a loop in code. Loop code is
just a poor way to use the OOPic.

A final thought: the OOPic just doesn't handle serial input very well.
Even with oSerialPort, the buffer is too small.

Richard



Yahoo! Groups Links

<*> To visit your group on the web, go to:

http://groups.yahoo.com/group/oopic/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:

http://groups.yahoo.com/group/oopic/join

(Yahoo! ID required)

<*> To change settings via email:
mailto:oopic-digest@yahoogroups.com
mailto:oopic-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
oopic-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:

http://docs.yahoo.com/info/terms/

No comments:

Post a Comment