Serial IO - COM Ports

Started by Yeshu777, June 14, 2023, 00:56:55

Previous topic - Next topic

col

#15
A couple of quick fixes would be:

1. Tell the underlying gcc compiler to allow the conversion of the c datatypes from 'char*' to 'const unsigned char*' by adding
ModuleInfo "CC_OPTS: -fpermissive"
below any other ModuleInfo entries the main module file (bah.mod/serial.mod/serial.bmx). While this will work it's kinda 'naughty' as you're telling the compiler to ignore the error and continue building anyway (which turns out to ok here).

or 2. Correct the error stated by replacing each one of these:
= bbStringFromUTF8String((char*)buffer);
with
= bbStringFromUTF8String((const unsigned char*)buffer);

Edit: Looks like Derron beat me :)
https://github.com/davecamp

"When you observe the world through social media, you lose your faith in it."

funkheld

BlitzMax_win32_x64_mingw_0.136.3.51.7z

I have now installed this. again an error. greeting


Building Modules
[  0%] Processing:common.bmx
[  0%] Processing:source.bmx
[  0%] Processing:common.bmx
[  4%] Processing:regex.bmx
[  4%] Processing:regex.bmx
[  5%] Processing:common.bmx
[  6%] Processing:serial.bmx
[ 14%] Compiling:pcre2_auto_possess.c
[ 14%] Compiling:pcre2_chartables.c
[ 14%] Compiling:pcre2_compile.c
[ 14%] Compiling:pcre2_config.c
[ 14%] Compiling:pcre2_context.c
[ 15%] Compiling:pcre2_dfa_match.c
[ 15%] Compiling:pcre2_error.c
[ 15%] Compiling:pcre2_extuni.c
[ 15%] Compiling:pcre2_find_bracket.c
[ 15%] Compiling:pcre2_jit_compile.c
[ 15%] Compiling:pcre2_maketables.c
[ 15%] Compiling:pcre2_match.c
[ 15%] Compiling:pcre2_match_data.c
[ 15%] Compiling:pcre2_newline.c
[ 15%] Compiling:pcre2_ord2utf.c
[ 15%] Compiling:pcre2_pattern_info.c
[ 15%] Compiling:pcre2_string_utils.c
[ 15%] Compiling:pcre2_study.c
[ 15%] Compiling:pcre2_substitute.c
[ 15%] Compiling:pcre2_substring.c
[ 15%] Compiling:pcre2_tables.c
[ 15%] Compiling:pcre2_ucd.c
[ 15%] Compiling:pcre2_valid_utf.c
[ 15%] Compiling:pcre2_xclass.c
[ 15%] Compiling:glue.cpp
[ 15%] Compiling:list_win32.cpp
[ 15%] Compiling:win.cc
D:/BlitzMax/mod/Bah.mod/serial.mod/glue.cpp: In function 'void bmx_serial_throw_serialexception(serial::SerialException&)':
D:/BlitzMax/mod/Bah.mod/serial.mod/glue.cpp:105:93: error: invalid conversion from 'const char*' to 'const unsigned char*' [-fpermissive]
  105 |        bbExThrow(CB_PREF(bah_serial_TSerialException__create)(bbStringFromUTF8String(e.what())));
      |                                                                                      ~~~~~~^~
      |                                                                                            |
      |                                                                                            const char*
In file included from D:/BlitzMax/mod/brl.mod/blitz.mod/blitz.h:37,
                from D:/BlitzMax/mod/Bah.mod/serial.mod/glue.cpp:29:
D:/BlitzMax/mod/brl.mod/blitz.mod/blitz_string.h:129:55: note:  initializing argument 1 of 'BBString* bbStringFromUTF8String(const unsigned char*)'
  129 | BBString*bbStringFromUTF8String( const unsigned char *p );
      |                                  ~~~~~~~~~~~~~~~~~~~~~^
D:/BlitzMax/mod/Bah.mod/serial.mod/glue.cpp: In function 'void bmx_serial_throw_ioexception(serial::IOException&)':
D:/BlitzMax/mod/Bah.mod/serial.mod/glue.cpp:109:89: error: invalid conversion from 'const char*' to 'const unsigned char*' [-fpermissive]
  109 |        bbExThrow(CB_PREF(bah_serial_TIOException__create)(bbStringFromUTF8String(e.what())));
      |                                                                                  ~~~~~~^~
      |                                                                                        |
      |                                                                                        const char*
D:/BlitzMax/mod/brl.mod/blitz.mod/blitz_string.h:129:55: note:  initializing argument 1 of 'BBString* bbStringFromUTF8String(const unsigned char*)'
  129 | BBString*bbStringFromUTF8String( const unsigned char *p );
      |                                  ~~~~~~~~~~~~~~~~~~~~~^
D:/BlitzMax/mod/Bah.mod/serial.mod/glue.cpp: In function 'void bmx_serial_throw_portnotopenexception(serial::PortNotOpenedException&)':
D:/BlitzMax/mod/Bah.mod/serial.mod/glue.cpp:113:100: error: invalid conversion from 'const char*' to 'const unsigned char*' [-fpermissive]
  113 |        bbExThrow(CB_PREF(bah_serial_TPortNotOpenedException__create)(bbStringFromUTF8String(e.what())));
      |                                                                                              ~~~~~~^~
      |                                                                                                    |
      |                                                                                                    const char*
D:/BlitzMax/mod/brl.mod/blitz.mod/blitz_string.h:129:55: note:  initializing argument 1 of 'BBString* bbStringFromUTF8String(const unsigned char*)'
  129 | BBString*bbStringFromUTF8String( const unsigned char *p );
      |                                  ~~~~~~~~~~~~~~~~~~~~~^
D:/BlitzMax/mod/Bah.mod/serial.mod/glue.cpp: In function 'serial::Serial* bmx_serial_create(BBString*, int, MaxTimeout*, int, int, int, int)':
D:/BlitzMax/mod/Bah.mod/serial.mod/glue.cpp:125:56: error: invalid conversion from 'unsigned char*' to 'char*' [-fpermissive]
  125 |                        char * s = bbStringToUTF8String(port);
      |                                    ~~~~~~~~~~~~~~~~~~~~^~~~~~
      |                                                        |
      |                                                        unsigned char*
D:/BlitzMax/mod/Bah.mod/serial.mod/glue.cpp:134:101: error: invalid conversion from 'const char*' to 'const unsigned char*' [-fpermissive]
  134 |                bbExThrow(CB_PREF(bah_serial_TSerialException__create)(bbStringFromUTF8String(e.what())));
      |                                                                                              ~~~~~~^~
      |                                                                                                    |
      |                                                                                                    const char*
D:/BlitzMax/mod/brl.mod/blitz.mod/blitz_string.h:129:55: note:  initializing argument 1 of 'BBString* bbStringFromUTF8String(const unsigned char*)'
  129 | BBString*bbStringFromUTF8String( const unsigned char *p );
      |                                  ~~~~~~~~~~~~~~~~~~~~~^
D:/BlitzMax/mod/Bah.mod/serial.mod/glue.cpp: In function 'BBString* bmx_serial_readline(serial::Serial*, int, BBString*)':
D:/BlitzMax/mod/Bah.mod/serial.mod/glue.cpp:191:40: error: invalid conversion from 'unsigned char*' to 'char*' [-fpermissive]
  191 |        char * s = bbStringToUTF8String(eol);
      |                    ~~~~~~~~~~~~~~~~~~~~^~~~~
      |                                        |
      |                                        unsigned char*
D:/BlitzMax/mod/Bah.mod/serial.mod/glue.cpp:196:74: error: invalid conversion from 'const char*' to 'const unsigned char*' [-fpermissive]
  196 |                ret = bbStringFromUTF8String(ser->readline(size, s).c_str());
      |                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
      |                                                                          |
      |                                                                          const char*
D:/BlitzMax/mod/brl.mod/blitz.mod/blitz_string.h:129:55: note:  initializing argument 1 of 'BBString* bbStringFromUTF8String(const unsigned char*)'
  129 | BBString*bbStringFromUTF8String( const unsigned char *p );
      |                                  ~~~~~~~~~~~~~~~~~~~~~^
D:/BlitzMax/mod/Bah.mod/serial.mod/glue.cpp: In function 'int bmx_serial_writestring(serial::Serial*, BBString*)':
D:/BlitzMax/mod/Bah.mod/serial.mod/glue.cpp:232:40: error: invalid conversion from 'unsigned char*' to 'char*' [-fpermissive]
  232 |        char * s = bbStringToUTF8String(data);
      |                    ~~~~~~~~~~~~~~~~~~~~^~~~~~
      |                                        |
      |                                        unsigned char*
D:/BlitzMax/mod/Bah.mod/serial.mod/glue.cpp: In function 'void bmx_serial_setport(serial::Serial*, BBString*)':
D:/BlitzMax/mod/Bah.mod/serial.mod/glue.cpp:255:40: error: invalid conversion from 'unsigned char*' to 'char*' [-fpermissive]
  255 |        char * s = bbStringToUTF8String(port);
      |                    ~~~~~~~~~~~~~~~~~~~~^~~~~~
      |                                        |
      |                                        unsigned char*
D:/BlitzMax/mod/Bah.mod/serial.mod/glue.cpp: In function 'BBString* bmx_serial_getport(serial::Serial*)':
D:/BlitzMax/mod/Bah.mod/serial.mod/glue.cpp:273:59: error: invalid conversion from 'const char*' to 'const unsigned char*' [-fpermissive]
  273 |        return bbStringFromUTF8String(ser->getPort().c_str());
      |                                      ~~~~~~~~~~~~~~~~~~~~^~
      |                                                          |
      |                                                          const char*
D:/BlitzMax/mod/brl.mod/blitz.mod/blitz_string.h:129:55: note:  initializing argument 1 of 'BBString* bbStringFromUTF8String(const unsigned char*)'
  129 | BBString*bbStringFromUTF8String( const unsigned char *p );
      |                                  ~~~~~~~~~~~~~~~~~~~~~^
Build Error: failed to compile (1) D:/BlitzMax/mod/Bah.mod/serial.mod/glue.cpp
Process complete

col

Looks like the same error. I really have no idea why bbStringFromUTF8String has a 'const unsigned char*' signature? Normally 'const char*' is enough but hey hey :)

Did you try my solution #1 above at all? If it works then you shouldn't have to update all of the instances of the error(s) in the .cc/.cpp source files.
https://github.com/davecamp

"When you observe the world through social media, you lose your faith in it."

Midimaster

This happened in 2021-04-29. @Brucey changed this in the brl.mod/blitz.mod/blitz_string.h and a lot of the old BAH.MODs have now problems with it.

https://github.com/bmx-ng/brl.mod/commit/5...
...back from Egypt

funkheld

Hello, thank you, it works wonderfully now with the serial port.

 I have 2 serial USB adapters, RX to TX and TX to RX. 
can send data to two computers with it usb.

BlitzMax_win32_0.129.3.45.7z is ok.

wonderful. you've done a lot of work. 

Thanks. greeting

Midimaster

@funkheld 

I received a message from Brucey's GitHub that serial.mod is now part of a new module new io.mod., which willl become part of the official BlitzMax NG release. In this process serial.mod was updated and bugs were removed. This means serial mod will run on current versions of BlitzMax NG

The serial.mod inside Bah.mod is now obsolet and will stay there only for vintage versions of BlitzMax. ( f.e. BlitzMax_win32_0.129.3.45.7z )

New serial.mod: https://github.com/bmx-ng/io.mod
...back from Egypt