Browsing this Thread:
1 Anonymous Users
|
Re: Open serial device, error passing parameter
|
||||
|---|---|---|---|---|
|
Quite a regular
![]()
|
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
|
|||
|
||||
|
Re: Open serial device, error passing parameter
|
||||
|---|---|---|---|---|
|
Home away from home
![]()
|
Quote:
Is it required to cast 'serialIO' to PTR TO io? 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 |
|||
|
||||
|
Re: Open serial device, error passing parameter
|
||||
|---|---|---|---|---|
|
Quite a regular
![]()
|
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
|
|||
|
||||
|
Open serial device, error passing parameter
|
||||
|---|---|---|---|---|
|
Quite a regular
![]()
|
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
|
|||
|
||||
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.





