Ariane Soft PPL2 Pocket Programming DataMite

Go Back   ArianeSoft Forums > PPL - Pocket Programming Language > Support

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-19-2010, 07:01 PM
juppmaifeld juppmaifeld is offline
Member
 
Join Date: Aug 2009
Posts: 43
Question Configuring COM Port with SetCommState fails for fOutxDsrFlow$ and fOutxDsrFlow$

Hi,

I do have a problem configuring the COM port settings fOutxCtsFlow$ and fOutxDsrFlow$ of the dcb structure with SetCommState.

Find attached the little test prog with my comments. I tried it with ppl 1.53 and ppl 1.62 on a intel pc (native RS232 harware, no USB <-> RS232 adapter) and a IPAQ with windows mobile 5.0 with the same negative result. If somebody has an idea to solve the problem please let me know.

If you like to try the test prog just copy it from here and change the COM port to your needs (COM1/2/x).

Jupp

// Test prog


#include "comm.ppl"

//Problem: Configuring COM Port with SetCommState fails for fOutxDsrFlow$ and fOutxDsrFlow$

// Open port !!! For trying the testprog change COM port to yuor necessity !!!
p$ = CreateFile("COM1", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);

// Input and Output buffer size
SetupComm(p$, 128, 128);

// Setup port
struct(dcb$, DCB);
dcb.DCBlength$ = sizeof(dcb$);

GetCommState(p$, &dcb$);

// The call of SetCommState after each dcb.xx setting is just for test purpose to find out
// which dcb setting works and which not

dcb.BaudRate$ = 9600;
if (SetCommState(p$, &dcb$) == FALSE)
error$ = GetLastError();
ShowMessage("1-Error: SetCommState BaudRate$ => false; ErrorCode:" + error$);
end;

dcb.ByteSize$ = 8;
if (SetCommState(p$, &dcb$) == FALSE)
error$ = GetLastError();
ShowMessage("2-Error: SetCommState ByteSize$ => false; ErrorCode:" + error$);
end;

dcb.Parity$ = NOPARITY;
if (SetCommState(p$, &dcb$) == FALSE)
error$ = GetLastError();
ShowMessage("3-Error: SetCommState Parity$ => false; ErrorCode:" + error$);
end;

dcb.StopBits$ = ONESTOPBIT;
if (SetCommState(p$, &dcb$) == FALSE)
error$ = GetLastError();
ShowMessage("4-Error: SetCommState StopBits$ => false; ErrorCode:" + error$);
end;

dcb.fAbortOnError$ = FALSE;
if (SetCommState(p$, &dcb$) == FALSE)
error$ = GetLastError();
ShowMessage("5-Error: SetCommState fAbortOnError$ => false; ErrorCode:" + error$);
end;

dcb.fBinary$ = TRUE;
if (SetCommState(p$, &dcb$) == FALSE)
error$ = GetLastError();
ShowMessage("6-Error: SetCommState fBinary$ => false; ErrorCode:" + error$);
end;

dcb.fDsrSensitivity$ = FALSE;
if (SetCommState(p$, &dcb$) == false)
error$ = GetLastError();
ShowMessage("7-Error: SetCommState fDsrSensitivity$ => false; ErrorCode:" + error$);
end;

// Set RTS/CTS Handshake for example

dcb.fDtrControl$ = DTR_CONTROL_DISABLE;
if (SetCommState(p$, &dcb$) == FALSE)
error$ = GetLastError();
ShowMessage("8-Error: SetCommState fDtrControl$ => false; ErrorCode:" + error$);
end;


dcb.fRtsControl$ = RTS_CONTROL_HANDSHAKE;
if (SetCommState(p$, &dcb$) == FALSE)
error$ = GetLastError();
ShowMessage("10-Error: SetCommState fRtsControl$ => false; ErrorCode:" + error$);
end;


dcb.fOutX$ = TRUE;
if (SetCommState(p$, &dcb$) == FALSE)
error$ = GetLastError();
ShowMessage("12-Error: SetCommState fOutX$ => false; ErrorCode:" + error$);
end;

dcb.fInX$ = TRUE;
if (SetCommState(p$, &dcb$) == FALSE)
error$ = GetLastError();
ShowMessage("13-Error: SetCommState fInX$ => false; ErrorCode:" + error$);
end;

// So far everything is okay...

//... but for setting fOutxDsrFlow$ = TRUE and fOutxCtsFlow$ = TRUE/FALSE
// I always get the Microsoft error code 87 -> ERROR_INVALID_PARAMETER, The parameter is incorrect.
// but according to the COMMPROP Structure Values of the selected CommPort ->
// dwProvCapabilities$ = DTR,DSR supported
// dwProvCapabilities$ = RTS, CTS supported
// these functionality is supported

dcb.fOutxDsrFlow$ = TRUE;
if (SetCommState(p$, &dcb$) == FALSE)
error$ = GetLastError();
ShowMessage("9-Error: SetCommState fOutxDsrFlow$ => false; ErrorCode:" + error$);
end;

dcb.fOutxCtsFlow$ = TRUE;
if (SetCommState(p$, &dcb$) == FALSE)
error$ = GetLastError();
ShowMessage("11-Error: SetCommState fOutxCtsFlow$ => false; ErrorCode:" + error$);
end;

CloseHandle(p$);


/*
COM1 COMMPROP Structure Values of the COM port that I used !!!!!
----------------------------------------------------------

wPacketLength$ = 64 (0x40)

wPacketLength$ = sizeof(commprop$) 64 (0x40)

wPacketVersion$ = 2 (0x02)

dwServiceMask$ = 1 (0x01)

dwMaxTxQueue$ = 0 => no default value

dwCurrentTxQueue$ = 0 (0x00)

dwMaxRxQueue$ = 0 => no default value

dwCurrentRxQueue$ = 4096 (0x1000)

dwProvSpec1$ = 0 (0x00)

dwProvSpec2$ = 0 (0x00)

wcProvCahr$ = 0 (0x00)

dwMaxBaud$ = 268435456 (0x10000000)

dwMaxBaud$ = Programmable baud rate

dwProvSubType$ = 1 (0x01)

dwProvSubType$ = RS-232 serial port

dwProvCapabilities$ = 255 (0xFF)

dwProvCapabilities$ = DTR,DSR supported

dwProvCapabilities$ = Interval timeouts supported

dwProvCapabilities$ = Parity checking supported

dwProvCapabilities$ = RLSD (receive-line-signal-detect) supported

dwProvCapabilities$ = RTS, CTS supported

dwProvCapabilities$ = Setable XON, XOFF supported

dwProvCapabilities$ = Total (elapsed) timeouts supported

dwProvCapabilities$ = XON,XOFF flow control supported

commprop.dwSettableParams$ = 127 (0x7F)

dwSettableParams$ = Handshaking (flow control)

dwSettableParams$ = Parity checking

dwSettableParams$ = RLSD (receive-line-signal-detect)

dwSettableParams$ = Baud rate

Setable Baud rate = 75 bps

Setable Baud rate = 110 bps

Setable Baud rate = 134.5 bps

Setable Baud rate = 150 bps

Setable Baud rate = 300 bps

Setable Baud rate = 600 bps

Setable Baud rate = 1200 bps

Setable Baud rate = 1800 bps

Setable Baud rate = 2400 bps

Setable Baud rate = 4800 bps

Setable Baud rate = 7200 bps

Setable Baud rate = 9600 bps

Setable Baud rate = 14400 bps

Setable Baud rate = 19200 bps

Setable Baud rate = 38400 bps

Setable Baud rate = 56000 bps

Setable Baud rate = 57600 bps

Setable Baud rate = 115200 bps

Setable Baud rate = Programmable Baud rate

dwSettableParams$ = Data bits

Setable Data bits = 5

Setable Data bits = 6

Setable Data bits = 7

Setable Data bits = 8

dwSettableParams$ = Parity

Setable Parity = No parity

Setable Parity = Odd parity

Setable Parity = Even parity

Setable Parity = Mark parity

Setable Parity = Space parity

dwSettableParams$ = Stop bits

Setable Parity = 1 stop bit

Setable Parity = 1.5 stop bit

Setable Parity = 2 stop bit

---------------------------------

*/

Last edited by juppmaifeld; 01-30-2010 at 11:10 AM.
Reply With Quote
  #2  
Old 01-20-2010, 04:44 PM
juppmaifeld juppmaifeld is offline
Member
 
Join Date: Aug 2009
Posts: 43
Smile

Hi,

anybody out there?

No response so far.

Are you all on vacation?

Need help with the problem.

Jupp
Reply With Quote
  #3  
Old 01-21-2010, 02:34 PM
Nicknack Nicknack is offline
Senior Member
 
Join Date: Nov 2006
Location: Germany
Posts: 527
Default

I don't have experience with RS232 , so I can give you only some general tips:
1. are you sure the call has failed, have you tried to check the result with getcommstate?
2. is there any difference if you change the order of your setcommstate calls or if you make all changes in one call?
3. consider the remak section on msdn:
Quote:
...
To set only a few members of the DCB structure, you should modify a DCB structure that has been filled in by a call to GetCommState. This ensures that the other members of the DCB structure have appropriate values.

The SetCommState function fails if the XonChar member of the DCB structure is equal to the XoffChar member.
.....
Reply With Quote
  #4  
Old 01-21-2010, 05:18 PM
juppmaifeld juppmaifeld is offline
Member
 
Join Date: Aug 2009
Posts: 43
Smile

Hi Nicknack,

thanks for your answer.

Question 1:
Yes I am sure the call failed. Try the updated test prog to see the result.

Question 2:
See my remark in the test prog.
// The call of SetCommState after each dcb.xx setting is just for test purpose to find out which dcb setting works and which not.
In my prog I first setup the whole dcb struct and then I call SetCommstate once only. Concerning the order of setting the dcb values I am almost sure it is independent.

Question 3:
I am aware of that. I added XonChar, XofChar (XonChar != XoffChar) to the test prog to show that the errors setting fOutxCtsFlow$ and fOutxDsrFlow$ are still there.

I did a lot of testing concerning the problem. I can't find anything wrong with how I handle the dcb settings. I also looked intensively into the dcb structure definition itself, changed and tested a lot of different things, but the problem did not disappear. Maybe it is a question of the underlying comm port hardware. I tested it on different hardware as I described it in my initial post but with no success.

I attach the updated test prog to this post again so that maybe others can try it out. Just copy it to the PIDE and do a RUN.

Jupp


#include "comm.ppl"

//Problem: Configuring COM Port with SetCommState fails for fOutxDsrFlow$ and fOutxDsrFlow$

// Open port !!! For trying the testprog change COM port to yuor necessity !!!
p$ = CreateFile("COM1", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);

// Input and Output buffer size
SetupComm(p$, 128, 128);

// Setup port
struct(dcb$, DCB);
dcb.DCBlength$ = sizeof(dcb$);

struct(dcb0$, DCB);
dcb0.DCBlength$ = sizeof(dcb0$);

GetCommState(p$, &dcb$);
GetCommState(p$, &dcb0$);

// The call of SetCommState after each dcb.xx setting is just for test purpose to find out
// which dcb setting works and which not

dcb.BaudRate$ = 9600;
if (SetCommState(p$, &dcb$) == FALSE)
error$ = GetLastError();
ShowMessage("1-Error: SetCommState BaudRate$ => false; ErrorCode:" + error$);
end;

dcb.ByteSize$ = 8;
if (SetCommState(p$, &dcb$) == FALSE)
error$ = GetLastError();
ShowMessage("2-Error: SetCommState ByteSize$ => false; ErrorCode:" + error$);
end;

dcb.Parity$ = NOPARITY;
if (SetCommState(p$, &dcb$) == FALSE)
error$ = GetLastError();
ShowMessage("3-Error: SetCommState Parity$ => false; ErrorCode:" + error$);
end;

dcb.StopBits$ = ONESTOPBIT;
if (SetCommState(p$, &dcb$) == FALSE)
error$ = GetLastError();
ShowMessage("4-Error: SetCommState StopBits$ => false; ErrorCode:" + error$);
end;

dcb.fAbortOnError$ = FALSE;
if (SetCommState(p$, &dcb$) == FALSE)
error$ = GetLastError();
ShowMessage("5-Error: SetCommState fAbortOnError$ => false; ErrorCode:" + error$);
end;

dcb.fBinary$ = TRUE;
if (SetCommState(p$, &dcb$) == FALSE)
error$ = GetLastError();
ShowMessage("6-Error: SetCommState fBinary$ => false; ErrorCode:" + error$);
end;

dcb.fDsrSensitivity$ = FALSE;
if (SetCommState(p$, &dcb$) == false)
error$ = GetLastError();
ShowMessage("7-Error: SetCommState fDsrSensitivity$ => false; ErrorCode:" + error$);
end;

// Set RTS/CTS Handshake for example

dcb.fDtrControl$ = DTR_CONTROL_DISABLE;
if (SetCommState(p$, &dcb$) == FALSE)
error$ = GetLastError();
ShowMessage("8-Error: SetCommState fDtrControl$ => false; ErrorCode:" + error$);
end;


dcb.fRtsControl$ = RTS_CONTROL_HANDSHAKE;
if (SetCommState(p$, &dcb$) == FALSE)
error$ = GetLastError();
ShowMessage("10-Error: SetCommState fRtsControl$ => false; ErrorCode:" + error$);
end;


dcb.fOutX$ = TRUE;
if (SetCommState(p$, &dcb$) == FALSE)
error$ = GetLastError();
ShowMessage("12-Error: SetCommState fOutX$ => false; ErrorCode:" + error$);
end;

dcb.fInX$ = TRUE;
if (SetCommState(p$, &dcb$) == FALSE)
error$ = GetLastError();
ShowMessage("13-Error: SetCommState fInX$ => false; ErrorCode:" + error$);
end;

dcb.XonChar$ = 0x11;
if (SetCommState(p$, &dcb$) == FALSE)
error$ = GetLastError();
ShowMessage("14-Error: SetCommState XonChar$ => false; ErrorCode:" + error$);
end;

dcb.XoffChar$ = 0x13;
if (SetCommState(p$, &dcb$) == FALSE)
error$ = GetLastError();
ShowMessage("14-Error: SetCommState XonOff$ => false; ErrorCode:" + error$);
end;

// So far everything is okay...

//... but for setting fOutxDsrFlow$ = TRUE and fOutxCtsFlow$ = TRUE/FALSE
// I always get the Microsoft error code 87 -> ERROR_INVALID_PARAMETER, The parameter is incorrect.
// but according to the COMMPROP Structure Values of the selected CommPort ->
// dwProvCapabilities$ = DTR,DSR supported
// dwProvCapabilities$ = RTS, CTS supported
// these functionality is supported



dcb.fOutxDsrFlow$ = TRUE;
if (SetCommState(p$, &dcb$) == FALSE)
error$ = GetLastError();
ShowMessage("9-Error: SetCommState fOutxDsrFlow$ => false; ErrorCode:" + error$);
end;

GetCommState(p$, &dcb$);
ShowMessage("dcb0.fOutxDsrFlow$ = " + dcb0.fOutxDsrFlow$ + "\n" + "dcb.fOutxDsrFlow$ = " + dcb.fOutxDsrFlow$);

dcb.fOutxCtsFlow$ = TRUE;
if (SetCommState(p$, &dcb$) == FALSE)
error$ = GetLastError();
ShowMessage("11-Error: SetCommState fOutxCtsFlow$ => false; ErrorCode:" + error$);
end;

GetCommState(p$, &dcb$);
ShowMessage("dcb0.fOutxCtsFlow$ = " + dcb0.fOutxCtsFlow$ + "\n" + "dcb.fOutxCtsFlow$ = " + dcb.fOutxCtsFlow$);

Last edited by juppmaifeld; 01-30-2010 at 11:11 AM.
Reply With Quote
  #5  
Old 01-30-2010, 11:39 AM
juppmaifeld juppmaifeld is offline
Member
 
Join Date: Aug 2009
Posts: 43
Default

Hi Kornalius,

I did add the issue to the bug report becuse in my opinion this is an major error that should be solved. If it is not, I will take the blame on me.

Jupp
Reply With Quote
  #6  
Old 04-07-2010, 07:05 PM
juppmaifeld juppmaifeld is offline
Member
 
Join Date: Aug 2009
Posts: 43
Unhappy

Hi all,

no response so far? Nobody at arianesoft interested in solving this issue or all the other issues at the bug report? Kornalius are you just a one man band at arianesoft so that if you are busy nobody else can solve the problems with ppl? Concerning the bug report there are a lot of problems with ppl not solved yet and it appears to me that nothing happens.

Regards

Jupp
Reply With Quote
  #7  
Old 04-07-2010, 10:59 PM
Nicknack Nicknack is offline
Senior Member
 
Join Date: Nov 2006
Location: Germany
Posts: 527
Default

hi Jupp,
have a look at kornalius response in my thread.
Reply With Quote
  #8  
Old 04-08-2010, 01:58 PM
kornalius kornalius is offline
Administrator
 
Join Date: Apr 2006
Posts: 551
Default

Yep, ArianeSoft is a one man band concerning PPL. I am devoting all my time on an iPhone game to allow ArianeSoft to survive the year. I have put PPL on hiatus for some time. I hope to find time to work on it very soon.
__________________
Regards,
Alain Deschenes
ArianeSoft Inc.
http://www.arianesoft.ca
Reply With Quote
  #9  
Old 04-08-2010, 05:06 PM
juppmaifeld juppmaifeld is offline
Member
 
Join Date: Aug 2009
Posts: 43
Default

That's pity. Ever thought about making PPL "Open Source"? So that maybe the community (Nicknack, Zehlein, ...) could do some of the work.

Jupp
Reply With Quote
  #10  
Old 04-09-2010, 03:22 AM
kornalius kornalius is offline
Administrator
 
Join Date: Apr 2006
Posts: 551
Default Re: Configuring COM Port with SetCommState fails for fOutxDsrFlow$ and fOutxDsrFlow$

At this point PPL is still a product I want to keep in the line up. I have not abandonned it in anyway. I have put my heart and soul in it for 6 years. It will rest for a couple months inactive and development will resume.
__________________
Regards,
Alain Deschenes
ArianeSoft Inc.
http://www.arianesoft.ca
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:47 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright (c) ArianeSoft Inc.
Copyright © 2009 www.ppl-lang.com - All rights reserved
Web Design by BR Web Consulting Ltd