Silly Com1 question
Silly Com1 question
Im sure a stupid question, but i've been through docs and cant find the answer.
How do I adjust the speed of com1. Im using the following but its not changing it from the default of 19200
Call OpenCom(1, 9600, iq, oq)
Im calling this as the first item in Main()
I can change it using Option Com1Speed 9600 , but not inline code. What am i doing wrong?
How do I adjust the speed of com1. Im using the following but its not changing it from the default of 19200
Call OpenCom(1, 9600, iq, oq)
Im calling this as the first item in Main()
I can change it using Option Com1Speed 9600 , but not inline code. What am i doing wrong?
Re: Silly Com1 question
The second sentence in the Discussion section of the OpenCom() documentation says: "If the specified channel is already open [...] it has no effect." The point that you may be overlooking is that Com1 is automatically opened for you prior to Main() being executed. Consequently, if the first statement in Main() is an OpenCom() call, it will necessarily fail.sturgessb wrote:I can change it using Option Com1Speed 9600 , but not inline code.
One other item that requires attention is that the queues supplied to OpenCom() must be initialized (using OpenQueue()) so those calls must precede the OpenCom() call. The usual way of doing this is:
Code: Select all
Call OpenQueue(iq, SizeOf(iq))
Call OpenQueue(oq, SizeOf(oq))
Call CloseCom(1, 0, 0)
Call OpenCom(1, 9600, iq, oq)
Code: Select all
Dim rxQ() as Byte Based Register.RxQueue
Dim txQ() as Byte Based Register.TxQueue
Call CloseCom(1, 0, 0)
Call OpenCom(1, 9600, rxQ, txQ)
- Don Kinzer
Short answer: because the serial transmission rate (baud rate) is not infinite.sturgessb wrote:If Com1 and Com2 are hardware channels, why do console.write and console.read cause delays?
Any call that adds data to a queue (which Debug.Print and Console.Write do) will incur a non-zero delay. If the queue has sufficient free space for the data being added, the delay will be relatively short. This time is required to copy the data to the queue and then adjust the queue management data elements to indicate the presence of the new data.
If the queue does not have sufficient free space, the routine must wait until there is. That wait time depends on how long it takes the queue's "consumer" to remove data from the queue. In the case of an output queue associated with a serial port (whether hardware- or software-based) the wait time will typically be 10/baudRate seconds for each byte.
- Don Kinzer
Register.Console.Echosturgessb wrote:Also, echo is on by default, I can't see how I turn that off?
- Don Kinzer
The Options section of the manual contains an exhaustive list of the compiler directives/options that are available. Some of them overlap with compiler command line options (which can be placed in your .pjt file, preceding the list of files in the project).sturgessb wrote:I thought they were like Options, I was trying to set outside Main().
There is a lot of information to digest; too much to read and comprehend all at once. However, you would probably be well served to take the time to leaf through the manual just to get a feel for what is available.
- Don Kinzer
I am having problem with receiving serial data on com1.
I have simple VB app that send out the following string every second.
"17,1200,2222,3333"
And then a simple app on the zx that just does Console.ReadLine every second. The echo coming back from the zx is as follows
17,1200,2222,3333
17,1200,2222,3333
17,,2222,3333
17,1200,223
17,1200,2222,3333
17,1200,2222,3333
17,1200,2222,3333
17222217,12003
17,1200,2222,3
117,1200,222217,1203
17222,3333
17,1200
17,1200,2222,333
17,1,3333
1700,2222,3333
17,,3333
17,1200,2222,3333
17,1200,2222,333317,1200,22
As you can see its not quite the
17,1200,2222,3333
17,1200,2222,3333
17,1200,2222,3333
17,1200,2222,3333
etc etc, I was expecting.
I have tried at different baud rates, always the same. Queue size is more than adequate at 100bytes.
I've used a software serial port logger, and that indicates the data going out from the VB app is sound.
Any ideas?
Ben
I have simple VB app that send out the following string every second.
"17,1200,2222,3333"
And then a simple app on the zx that just does Console.ReadLine every second. The echo coming back from the zx is as follows
17,1200,2222,3333
17,1200,2222,3333
17,,2222,3333
17,1200,223
17,1200,2222,3333
17,1200,2222,3333
17,1200,2222,3333
17222217,12003
17,1200,2222,3
117,1200,222217,1203
17222,3333
17,1200
17,1200,2222,333
17,1,3333
1700,2222,3333
17,,3333
17,1200,2222,3333
17,1200,2222,333317,1200,22
As you can see its not quite the
17,1200,2222,3333
17,1200,2222,3333
17,1200,2222,3333
17,1200,2222,3333
etc etc, I was expecting.
I have tried at different baud rates, always the same. Queue size is more than adequate at 100bytes.
I've used a software serial port logger, and that indicates the data going out from the VB app is sound.
Any ideas?
Ben
Not if you must use PulseIn(). The problem is that in order to collect accurate data on the pulse, interrupts are disabled for the duration of the call. If that period approaches about 20 bit times (two character times) or more, serial input characters will be missed. Using a lower serial rate may mitigate the problem.sturgessb wrote:Any way around this.
Depending on the specifics of your application, you may be able to use InputCapture() instead of PulseIn(). The difference is that whereas PulseIn() is implemented entirely in software, InputCapture() uses hardware of the AVR chip to time the high and low segments of the input signal.
- Don Kinzer