Shop OBEX P1 Docs P2 Docs Learn Events
Suggestions on implementing a gethostbyname() function... — Parallax Forums

Suggestions on implementing a gethostbyname() function...

Farmer ScottFarmer Scott Posts: 30
edited 2009-03-21 01:13 in Propeller 1
So, I'm working on 'dns.spin', well, actually just the gethostbyname() function.· Before I get too far along, I've got some question about object interaction.· I'm wondering if what I have in mind will work...

Here's the code and object relationship...

main.spin
··· |- dns.spin
··· |- api_telnet_serial.spin
··········· |- driver_socket.spin
··················· |- driver_enc28j60.spin

The big question is, if I call the api_telnet_serial.start() function from main.spin, which will of course call the same function in driver_socket and driver_enc28j60, can I still call the api_telnet_serial.connect() function from dns.spin?

Sorry, I realize this is probably a little confusing, at least I am certainly confusing myself, but not exactly sure how to proceed.· I can usually get by with SPIN, but this is one conundrum that's got me perplexed...

Or, does anyone have any suggestions on a good way to implement this function?

Thanks,

Scott

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-03-21 01:13
    It's possible to write the lower level objects so they can be called as you want. You have to put the global variables in each object into a DAT section rather than a VAR section because each instance of an object has its own VAR area, but the DAT areas are shared. Main would then call api_telnet_serial and dns could also have api_telnet_serial. There would be only one copy of the code and of the DAT section(s).

    Do keep in mind that the object structure in Spin is not really designed for this kind of use, but people have done it using DAT sections. Look in the ObEx for a version of FullDuplexSerial that was designed for shared use for debugging. That'll give you an idea of what's involved. It's pretty straightforward.
Sign In or Register to comment.