Serial port ?

Started by Robert Dunn, July 05, 2010, 01:11:04 PM

Previous topic - Next topic

Robert Dunn

Ok, I"m not going to lie here.  I need full access to a serial port, I see no class in here to add it...

Does anybody here no how to open a serial port ?

Thanks,

Robert

Paul Squires

Hi Robert - sorry, I can't help you with this one. I have no experience at all dealing with serial ports. You may need to ask this one over on the PB forums unless another FF3 user has experience in this.
Paul Squires
PlanetSquires Software

Robert Eaton

There is a sample in the \PBWin90\Samples\Comms folder.

Bob

Robert Dunn

Wow, that was so easy to do....

I Keep forgetting the fact that FF3 is a GUI for Power Basic.   I just looked up the comms sample in the pb9 folder, and presto instant comm port access !

I was able to open com1 using FF3 and send information out and receive information back.  So easy it was funny !

;D

Roger Garstang

Yeah, COM Ports are very easy in PB, I've wrote tons of apps in FireFly using them.  If you haven't already you will want to research Threads/Events/WaitObjects too since the ports are hardware and you can stop the current thread waiting on I/O.  There are some API calls I use every now and then since PB doesn't have a command to match for some advanced stuff- PurgeComm and SetCommTimeouts mostly.

Peter House

Roger - do you have any sample code you could share?

I have done a good bit of serial using PB9 and have not used threads for that portion of the code.

It would be really nice to model something like the mscomm control in VB6 only without the Unicode issues.

Thanks in Advance for whatever you might provide . . .  :)

Douglas McDonald

#6
Peter, the comm sample in PB9 is threaded.

The receive thread starts here:

Thread Function ReceiveData (ByVal hWnd As Long) As Long


The thread is created in PBmain:


    ' Create a "listen" thread to monitor input from the modem/serial port
    Thread Create ReceiveData(hDlg) To hThread

Hope this helps
Doug

btw, you really don't want anything like the mscomm control. you have so much more control with pb and it is very easy to use and is sooo much better.
Doug McDonald
KD5NWK
www.redforksoftware.com
Is that 1's and 0's or 0's and 1's?

Peter House

Familiarity Breads Contempt - Charles Dickens.

I have written a lot of Serial Code using VB6 to communicate with microcontrollers for debug and control (My Main Job).  The mscomm control was extremely buggy and the bugs changed with each new release and so did the workarounds.  It was the devil I knew.

Thanks for your post, It does seem pretty easy to use after a short test drive this morning.  I will begin using this and never look back!

Peter House

Doug,

BTW - 1 came before 0 so it must be 1's and 0's  :)

snip from http://en.wikipedia.org/wiki/0_%28number%29

Positional notation without the use of zero (using an empty space in tabular arrangements, or the word kha "emptiness") is known to have been in use in India from the 6th century. The earliest certain use of zero as a decimal positional digit dates to the 5th century mention in the text Lokavibhaga. The glyph for the zero digit was written in the shape of a dot, and consequently called bindu ("dot"). The dot had been used in Greece during earlier ciphered numeral periods.

The Hindu-Arabic numeral system (base 10) reached Europe in the 11th century, via the Iberian Peninsula through Spanish Muslims, the Moors, together with knowledge of astronomy and instruments like the astrolabe, first imported by Gerbert of Aurillac. For this reason, the numerals came to be known in Europe as "Arabic numerals". The Italian mathematician Fibonacci or Leonardo of Pisa was instrumental in bringing the system into European mathematics in 1202.

Douglas McDonald

#9
Peter,
I still don't know if I'm a 0 or 1 but my wife says I'm not a 10 :)

Glad to see another micro controller person here. I too do that 90% of the time. I've found that using Pb comms I can just read in the data type I need and not have to deal with strings all the time as with the mscomm control. You can do many cool things with the comms in PB.

What kind of MCU's do you use mostly? I ask this because since your on a basic language forum that you may be using Basic for MCU's. I use microchip PIC's 99% of the time and I use Proton PDS to write the firmware. I'd like to know if there is a good basic compiler for AVR's or TI parts if that is what you use. I have the 'C' compilers but I find it much faster to write in basic and there is little difference in code size or speed using Proton PDS(can't be said for other compilers). In fact some routines are faster than 'C' since it compiles to ASM using MPLAB.

Most of the interfacing I do now is USB not RS232. It works great

Doug
Doug McDonald
KD5NWK
www.redforksoftware.com
Is that 1's and 0's or 0's and 1's?