Forum Index
HomeZBasic Home   Forum RulesForum Rules   Forum FAQForum FAQ   MemberlistMemberlist   UsergroupsUsergroups   RSS FeedRSS Feed
Site SearchSite Search   LinksLinks   DownloadDownload   Digests and SubscriptionsDigests and Subscriptions
ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in   RegisterRegister
odd serial port problem

 
Post new topic   Reply to topic    Forum Index -> ZBasic Language
Author Message
spamiam



Joined: 13 Nov 2005
Posts: 689

Posted: 01 October 2008, 21:55 PM    Post subject: odd serial port problem Reply with quote

I have been using ports for a while, but this time it does not seem to work. I think I am missing something pretty basic. I am attempting to define COM1 and make it some arbitrary speed, but I am using 19200 for compatibility with the default speed settings.

After initializing everything, I use PutQueueStr() to send a string over COM1, but nothing comes through. If I use debug.print, then I get data both before and after I try to initialize and send data thru the queue.

What am I doing wrong?

-Tony

Code:
Sub Main()

Const InputQueueSize As Integer = 10
Const OutputQueueSize As Integer = 40
   
Dim InputQueue(1 To InputQueueSize) As Byte
Dim OutputQueue(1 To OutputQueueSize) As Byte

   Call OpenQueue(OutputQueue, OutputQueueSize)
   Call OpenQueue(InputQueue, InputQueueSize)

debug.print "test"   

   Call OpenCom(1, 19200, InputQueue, OutputQueue)


call putqueuestr(OutputQueue,"1234")

call sleep (1.0)

debug.print "q count: ";getqueuecount(OutputQueue)
debug.print
debug.print "q size: ";getqueuespace(OutputQueue)
debug.print "status: ";statuscom(1)


End Sub
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2593
Location: Portland, OR

Posted: 01 October 2008, 22:48 PM    Post subject: Re: odd serial port problem Reply with quote

spamiam wrote:
I think I am missing something pretty basic.
Perhaps this from the description of OpenCom():
Quote:
If the specified channel is already open or if the
channel number is invalid, it has no effect.

In the past, this aspect of the operation was, erroneously, not performed. Basically, this means that you must first close Com1 before you open it again.
Back to top
spamiam



Joined: 13 Nov 2005
Posts: 689

Posted: 01 October 2008, 23:04 PM    Post subject: Reply with quote

OK, that makes sense. But for COM1, the port isn't actually closed, it just reverts to the default speed (19.2K) and the default buffers. If I haven't opened COM1 myself, then what buffers do I specify if I want to close it?

Just to try ANYTHING, I gave CloseCom() the buffers that I am going to use eventhough they are not associated with the existing COM1 stream. This worked.

Why do the buffers need to be specified in the CloseCom() command? Doesn't the program/compiler already know that info from the previous OpenCom() command? Since the buffers are not cleared, then it appears that they are not used for the closure.

Is this requirement to close the port before opening it something new? I have never done it before , and I never had a problem opening Com1 to my specifications before.

-Tony
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2593
Location: Portland, OR

Posted: 02 October 2008, 0:27 AM    Post subject: Reply with quote

spamiam wrote:
Why do the buffers need to be specified in the CloseCom() command?
ZBasic has that requirement only because BasicX does. In reality, nothing is done with the queue parameters so it doesn't matter what you pass. Unlike, BasicX, ZBasic will allow you to use zero to specify a "null queue". Consequently, you can call it thusly:
Code:
Call CloseCom(1, 0, 0)

spamiam wrote:
Is this requirement to close the port before opening it something new?
The documentation has always specified that you must close a channel before you can open it. As indicated in my earlier response, the VM failed to enforce this requirement. That's why your code worked previously but does not now.
Back to top
spamiam



Joined: 13 Nov 2005
Posts: 689

Posted: 02 October 2008, 12:22 PM    Post subject: Reply with quote

When did the VM tart to enforce the need to close the comport before opening it? This is the first time that I ran up against it, but maybe I did not update my compiler as often as I should.

-Tony
Back to top
dlh



Joined: 15 Dec 2006
Posts: 285
Location: ~Cincinnati

Posted: 02 October 2008, 14:05 PM    Post subject: Reply with quote

spamiam wrote:
When did the VM tart to enforce the need to close the comport before opening it? This is the first time that I ran up against it, but maybe I did not update my compiler as often as I should.


I think it was 2.5.0.
Back to top
spamiam



Joined: 13 Nov 2005
Posts: 689

Posted: 02 October 2008, 15:21 PM    Post subject: Reply with quote

dlh wrote:
I think it was 2.5.0.

Ah, OK. That came out 6/08. I was hoping it was not substantially prior to that and I had simply not noticed for a year or 2.

-T
Back to top
mtreat



Joined: 28 Nov 2005
Posts: 10

Posted: 05 October 2008, 17:23 PM    Post subject: Reply with quote

I have had some software running for months in a pair of 1281s that uses one 1281 to send data to the other. I ungraded the firmware in them from 2.3 to 2.6 yesterday and I was not longer able to transfer serial data between them. After spending hours trying to figure a hardware problem I decided to reload 2.3 firmware back into the 1281s and they are now working flawless again.

I think there is more to this problem them opening and closing COM ports as I open the ports right in the beginning and don't do anything else but send and receive data.
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2593
Location: Portland, OR

Posted: 05 October 2008, 17:41 PM    Post subject: Reply with quote

mtreat wrote:
I think there is more to this problem[...]
Your experiment clearly demonstrates that a difference between v2.3 and v2.6 is affecting the way that your program runs. Could I get your application code so that I can take a look to try to determine what it might be?
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Forum Index -> ZBasic Language Time synchro. with the server - Timezone/DST with your computer
Page 1 of 1

 


All content Copyright © 2005-2012 Elba Corp. All Rights Reserved.
Opinions expressed in posts are those of the author and not necessarily those of Elba Corp.
Powered by phpBB © 2001, 2005 phpBB Group