znyul / stm32flash

Automatically exported from code.google.com/p/stm32flash
0 stars 1 forks source link

stm32flash fails on FreeBSD - fix included #44

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. compile stm32flash on FreeBSD
2. Try to use it with a stm32 board, like ./stm32flash /dev/cuaU0
3.

What is the expected output? What do you see instead?
Instead of giving device info, I get:
tingo@kg-core1$ ./stm32flash /dev/cuaU0
stm32flash - http://stm32flash.googlecode.com/

/dev/cuaU0: No such file or directory

What version of the product are you using? On what operating system?
Valid for both the one for download here, and the one from 
https://gitorious.org/stm32flash
I'm using FreeBSD:
tingo@kg-core1$ uname -a
FreeBSD kg-core1.kg4.no 8.4-STABLE FreeBSD 8.4-STABLE #0 r253646: Thu Jul 25 
10:12:31 UTC 2013
     root@kg-core1.kg4.no:/usr/obj/usr/src/sys/GENERIC  amd64

Please provide any additional information below.
The problem is that INPCK is a input flag in FreeBSD, not a control flag (not 
sure how it is in Linux), so when the code in serial_setup adds that to the 
control flags, written and read control flags differ, and the code fails.
Fix below (I fiddled with 'git format-patch' but didn't grok it):

tingo@kg-core1$ git diff
diff --git a/serial_posix.c b/serial_posix.c
index f4097b4..3cca7e1 100644
--- a/serial_posix.c
+++ b/serial_posix.c
@@ -105,8 +105,8 @@ serial_err_t serial_setup(serial_t *h, const serial_baud_t 
baud, const serial_bi

        switch(parity) {
                case SERIAL_PARITY_NONE: port_parity = 0;                       break;
-               case SERIAL_PARITY_EVEN: port_parity = INPCK | PARENB;          
break;
-               case SERIAL_PARITY_ODD : port_parity = INPCK | PARENB | PARODD; 
break;
+               case SERIAL_PARITY_EVEN: port_parity = PARENB;          break;
+               case SERIAL_PARITY_ODD : port_parity = PARENB | PARODD; break;

                default:
                        return SERIAL_ERR_INVALID_PARITY;

Original issue reported on code.google.com by tin...@gmail.com on 27 Sep 2013 at 10:42

GoogleCodeExporter commented 9 years ago
Thanks for the report and suggested patch.

On Linux, INPCK is "Enable input parity checking" and is a c_iflag (input 
modes) flag.

However the c_oflag (output modes) flag PARENB is "Enable parity generation  on 
output and parity checking for input", which I would think makes the former 
superfluous, and your patch should be fine.

In the current code these flags are all passed to the c_cflag so it does not 
seem to be by the book. I will check the history of this code and hopefully get 
to do some testing to verify.

Original comment by lists.to...@gmail.com on 27 Sep 2013 at 11:20

GoogleCodeExporter commented 9 years ago
And please try to use git format-patch. See 
http://code.google.com/p/stm32flash/issues/detail?id=41#c1 for step by step 
instructions.

Original comment by lists.to...@gmail.com on 27 Sep 2013 at 11:22

GoogleCodeExporter commented 9 years ago
Ok, here is my attempt for git format-patch. Hope it helps.

Original comment by tin...@gmail.com on 27 Sep 2013 at 11:42

Attachments:

GoogleCodeExporter commented 9 years ago
Perfect, thanks.

Original comment by lists.to...@gmail.com on 27 Sep 2013 at 11:50

GoogleCodeExporter commented 9 years ago
This has now been fixed in the official repository and is included in version 
0.3beta2.

Original comment by lists.to...@gmail.com on 9 Dec 2013 at 11:25