July 02, 2024, 02:44:18 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Serial com port library question

Started by Andy, September 22, 2015, 06:09:18 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

Why does the IWSetPort command fail?

It prints "success" for opening the port but...
It prints "Nope" instead of "set success" for IWSetPort.

int port = 3

openconsole

if IWOpenPort(port, 38400 )

  print "success"

endif

if IWSetPort(port, 8, 0, 1 )

  print "set success"

else

  print "Nope"

endif

dO:until inkey$ <> ""
closeconsole

IWClosePort(port)

end


Com 3 is correct, and I have tried both 9600 and 38400 for the baud rate, and 8 bytes, no parity, 1 stop bit are also correct.

Anyone any ideas?

Thanks,
Andy.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Egil

I also struggled with this once. Seems that IWSetPort always returns 0.
It's not really a big deal, you only have to check each parameter separately....  ;D ;D ;D


Support Amateur Radio  -  Have a ham  for dinner!

Andy

Thanks Egil as always!

Point noted.

Andy.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

Quote from: Egil on September 22, 2015, 09:46:14 AM
I also struggled with this once. Seems that IWSetPort always returns 0.
It's not really a big deal, you only have to check each parameter separately....  ;D ;D ;D
guess I need to update the help file then. Is that correct?
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Egil

Hi Larry,

The helpfile shows the information for IWOpenPort when IWSetPort is selected, So maybe you should update the helpfile anyway.

Egil
Support Amateur Radio  -  Have a ham  for dinner!

Andy

Okay, I'm now getting confused as I am wondering how to check the com port settings.

In the comm read example, we use GetCommState and SetCommState using the dcb1 defined variable.

If I use the Com library, with it's own defined commands, and the IWSetPort does not work, how do I set / check the settings for a com port by just using the library?

Do I mix the library commands and some from the comm read example?

Basically, with the library, how to I set / check 8 bytes, no parity, 1 stop bit?

Thanks,
Andy.
:)

Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Egil

Quote from: andy1966 on September 23, 2015, 12:12:08 AMIf I use the Com library, with it's own defined commands, and the IWSetPort does not work, how do I set / check the settings for a com port by just using the library?

IWSetport works as intended. But the Comlib Helpfile is not correct, at least not the version I have here. IWOpenPort is shown instead.

According to IWComlib.incc this is how it is declared:
IWSetPort(int port_number, int bits, int parity, int stopbits),int

It works just fine in my WTerm code.

If you mix commands from the library with something from the commread example, and have used the same declares as in the example, you will probably get a compiler error or warning saying "Multiple declaration of ...... " or something like that. But I have never tried this myself.


Good Luck!
Egil
Support Amateur Radio  -  Have a ham  for dinner!

Andy

Thanks Egil,

It just had me confused!

It's just the help file that's incorrect, the command does work.

Thanks again,
Andy.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.