Login
Username:

Password:

Remember me



Lost Password?

Register now!
Main Menu
Who is Online
63 user(s) are online (51 user(s) are browsing Forum)

Members: 0
Guests: 63

more...


Browsing this Thread:   1 Anonymous Users






Re: Open serial device, error passing parameter
#5
Quite a regular
Quite a regular


See User information
OK, I got it.
There is a struct 'iostd' in 'ioextser' which is defined in exec/io and contains the fields 'command', 'actual', etc.


Thanks,
Manfred

Posted on: 2017/1/15 9:03
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 


Re: Open serial device, error passing parameter
#4
Quite a regular
Quite a regular


See User information
OK, many thanks.
This worked so far.

Now, I'm trying to access fields of this structure, specifically io_Command, etc. and looking at the serial.e file I'm not exactly certain how to do that.
I've tried a couple of variations but to no success.
How do I read the definition of the structure?

Manfred

Posted on: 2017/1/14 22:29
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 


Re: Open serial device, error passing parameter
#3
Home away from home
Home away from home


See User information
Quote:
Is it required to cast 'serialIO' to PTR TO io?
Well, I've tried that, didn't work.
serialIO is of type PTR TO ioextser

In these kinds of cases, before you considering casting an AmigaOS pointer, check whether it's first member is of the type you need... However, in this case that won't quite work:

"serialIO.iostd" gets us close, however the compiler wants type "io" and this gets us type "iostd". And unfortunately AmigaOS sometimes defined similar objects without using inheritance, so there is no ".io" member we can use.

So yes, it turns out that casting is required. Since neither "io" nor "iostd" (nor ioextser) are defined as real sub-classes (since "C" doesn't have such a concept & AmigaOS was written for C), you must first cast to the closest parent class, which is actually just "PTR". Then you can cast to the other type. So this should work:

serialIO!!PTR!!PTR TO io

But to save a bit of typing, you can cheat & just use this:

serialIO!!PTR

This is very similar to casting something as "(void *)" in C. I do *not* recommend this for normal programs, since it increases the chance of bugs. However, when using some low-level AmigaOS stuff, you may end-up needing a lot of casting, so in that case it actually makes your program more readable (and so bugs less likely!)...

Posted on: 2017/1/14 20:05

Edited by PortablE on 2017/1/15 10:04:53
Edited by PortablE on 2017/1/15 10:05:43
ChrisH
--
Author of the PortablE programming language.
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 


Re: Open serial device, error passing parameter
#2
Quite a regular
Quite a regular


See User information
I just realized that I have opened a thread on this a couple of months ago.
My brain...
http://aros-exec.org/modules/newbb/viewtopic.php?topic_id=9497&forum=28


Manfred

Posted on: 2017/1/14 18:59
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 


Open serial device, error passing parameter
#1
Quite a regular
Quite a regular


See User information
Hi there.

Those are my first steps with PortablE.

I'm running into a problem with opening a serial device using OpenDevice() function:
IF 0 <> OpenDevice('serialpl2303.device', 0, serialIO, 0) THEN Raise(ERR_ODEV)

Here is the compiler output:
ERROR: parameter of incorrect type
LINE 17: IF 0 <> OpenDevice('serialpl2303.device', 0, serialIO, 0) THEN Raise(ERR_ODEV)
Hint: parameter has type PTR TO io, expression has type PTR TO ioextser.

Is it required to cast 'serialIO' to PTR TO io?
Well, I've tried that, didn't work.
serialIO is of type PTR TO ioextser

Manfred

Posted on: 2017/1/14 11:20
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 







You can view topic.
You cannot start a new topic.
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[Advanced Search]


Search
Top Posters
1 paolone
paolone
4462
2 nikolaos
nikolaos
4206
3 magorium
magorium
4095
4 phoenixkonsole
phoenixkonsole
3942
5 deadwood
deadwood
2917
6 ncafferkey
ncafferkey
2810
7 mazze
mazze
2222
8 Kalamatee
Kalamatee
2212
9 clusteruk
clusteruk
2114
Powered by XOOPS © 2001-2025 The XOOPS Project