Almost got a fingerprint sensor to work with a Z-Uno

I get this error: No matching member function for call to ‘write’

Some context.

I want this fingerprint sensor to work with my Z-Uno via Serial1. I could not get the libraries to work so i copied and changed all that code and put it in my sketch.

If I compile this for the Arduino Mega, it throws no error. If i compile it for the Z-Uno i get: “No matching member function for call to ‘write’”. This is at row 274. Can anyone shine some light at my problem?

Below is the snippet where the error is thrown. My code were too long to post so it is attached (ZUno_fp.ino), along with the original working files (FPC1020.zip) for the fingerprint sensor.

// Send command
void UART_SendPackage(unsigned char wLen,unsigned char *ptr)
{
  unsigned int i=0,len=0;
 
  tBuf[0] = DATA_START;     //command head
  for(i = 0; i < wLen; i++)      // data in packet 
  {
    tBuf[1+i] = *(ptr+i);
  } 
  
  tBuf[wLen + 1] = CmdGenCHK(wLen, ptr);         //Generate checkout data
  tBuf[wLen + 2] = DATA_END;
  len = wLen + 3;
  
  g_ucUartRxEnd = 0;
  g_ucUartRxLen = len ;
  
 Serial1.write(tBuf,len);    // HERE IS THE ERROR

 // Serial.print((char *)tBuf);     
//  UartSend(tBuf,len);
}

FPC1020.zip (37.6 KB)

ZUno_fp.ino (12.9 KB)

Z-Uno has its own package; and I suspect that the problem is in their libraries. If you're lucky you will find somebody here that has used the Z-Uno but you're probably better of on their forum.

Anyway, you will have to post the full error message.

I want this fingerprint sensor to work with my Z-Uno via Serial1.

What the heck is a Z-Uno?

What type of array does write() expect? What type are you supplying? What type is the length argument supposed to be? What type are you supplying?

        MODE = Serial.read()-0x30;

By convention, all capital letter names are constants. Constants NEVER appear on the left of the = sign, except when initially valued.

                  User_ID = User_ID + (Serial.read()-0x30)*pow(10,(i-1));

Pow is a ridiculously expensive way to calculate 10 to the nth. Not even remotely necessary, either.

User_ID *= 10;
User_ID += Serial.read() - '0';

sterretje: Z-Uno has its own package; and I suspect that the problem is in their libraries. If you're lucky you will find somebody here that has used the Z-Uno but you're probably better of on their forum.

Anyway, you will have to post the full error message.

Error message:

Arduino:1.8.5 (Windows 7), Kort:"Z-Wave>ME Z-Uno, Europe, Disabled, Enabled, Disabled, Disabled"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Eric\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Eric\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries \\STABEDC1\Users$\Eric\Documents\Arduino\libraries -fqbn=Z-Uno:zw8051:zuno:Frequency=Eu,Security=Off,MuliCommand=On,LogOutput=Off,NVMClean=Off -ide-version=10805 -build-path C:\Users\Eric\AppData\Local\Temp\arduino_build_121923 -warnings=none -build-cache C:\Users\Eric\AppData\Local\Temp\arduino_cache_421634 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.zuno_toolchain.path=C:\Users\Eric\AppData\Local\Arduino15\packages\Z-Uno\tools\zuno_toolchain\00.08.70 -verbose \\STABEDC1\Users$\Eric\Documents\Eric\Privat\Arduino\ZUno_fp\ZUno_fp.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Eric\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Eric\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries \\STABEDC1\Users$\Eric\Documents\Arduino\libraries -fqbn=Z-Uno:zw8051:zuno:Frequency=Eu,Security=Off,MuliCommand=On,LogOutput=Off,NVMClean=Off -ide-version=10805 -build-path C:\Users\Eric\AppData\Local\Temp\arduino_build_121923 -warnings=none -build-cache C:\Users\Eric\AppData\Local\Temp\arduino_cache_421634 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.zuno_toolchain.path=C:\Users\Eric\AppData\Local\Arduino15\packages\Z-Uno\tools\zuno_toolchain\00.08.70 -verbose \\STABEDC1\Users$\Eric\Documents\Eric\Privat\Arduino\ZUno_fp\ZUno_fp.ino
Using board 'zuno' from platform in folder: C:\Users\Eric\AppData\Local\Arduino15\packages\Z-Uno\hardware\zw8051\2.1.4
Using core 'zuno' from platform in folder: C:\Users\Eric\AppData\Local\Arduino15\packages\Z-Uno\hardware\zw8051\2.1.4
Detecting libraries used...
"C:\Users\Eric\AppData\Local\Arduino15\packages\Z-Uno\tools\zuno_toolchain\00.08.70/zuno_toolchain/compiler" arduino_preproc  "C:\Users\Eric\AppData\Local\Temp\arduino_build_121923\sketch\ZUno_fp.ino.cpp"  -r "C:\Users\Eric\AppData\Local\Arduino15\packages\Z-Uno\hardware\zw8051\2.1.4"
Generating function prototypes...
"C:\Users\Eric\AppData\Local\Arduino15\packages\Z-Uno\tools\zuno_toolchain\00.08.70/zuno_toolchain/compiler" arduino_preproc  "C:\Users\Eric\AppData\Local\Temp\arduino_build_121923\sketch\ZUno_fp.ino.cpp"  -r "C:\Users\Eric\AppData\Local\Arduino15\packages\Z-Uno\hardware\zw8051\2.1.4"
"C:\Program Files (x86)\Arduino\tools-builder\ctags\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\Eric\AppData\Local\Temp\arduino_build_121923\preproc\ctags_target_for_gcc_minus_e.cpp"
Kompilerar skiss...
"C:\Users\Eric\AppData\Local\Arduino15\packages\Z-Uno\tools\zuno_toolchain\00.08.70/zuno_toolchain/compiler" build "C:\Users\Eric\AppData\Local\Temp\arduino_build_121923/ZUno_fp.ino" -r "C:\Users\Eric\AppData\Local\Arduino15\packages\Z-Uno\hardware\zw8051\2.1.4" -i1_8 -idv 10805


    ************* Building Arduino Sketch *************

    C:\Users\Eric\AppData\Local\Temp\arduino_build_121923/ZUno_fp.ino

    ***************************************************



     --- USING a list of libraries from:

        C:\Users\Eric\AppData\Local\Arduino15\packages\Z-Uno\hardware\zw8051\2.1.4\libraries

        \\STABEDC1\Users$\Eric\Documents\Arduino\libraries

    *** Collecting prototypes...

Preprocessing file: C:\Users\Eric\AppData\Local\Temp\arduino_build_121923\Custom.c with SDCPP... 

C:\Users\Eric\AppData\Local\Temp\arduino_build_121923\Custom.c:12:1: warning: "TRUE" redefined

In file included from C:\Users\Eric\AppData\Local\Temp\arduino_build_121923\/ZUNO_legacy_channels.h:3,

                 from C:\Users\Eric\AppData\Local\Temp\arduino_build_121923\Custom.c:6:

C:\Users\Eric\AppData\Local\Temp\arduino_build_121923\/ArduinoTypes.h:29:1: error: this is the location of the previous definition

C:\Users\Eric\AppData\Local\Temp\arduino_build_121923\Custom.c:13:1: warning: "FALSE" redefined

C:\Users\Eric\AppData\Local\Temp\arduino_build_121923\/ArduinoTypes.h:30:1: error: this is the location of the previous definition



Preprocessing file: C:\Users\Eric\AppData\Local\Temp\arduino_build_121923\Print.cpp with SDCPP... 

Compiling C:\Users\Eric\AppData\Local\Temp\arduino_build_121923\Print_sdcpp_.cpp ...

Preprocessing file: C:\Users\Eric\AppData\Local\Temp\arduino_build_121923\Stream.cpp with SDCPP... 

Compiling C:\Users\Eric\AppData\Local\Temp\arduino_build_121923\Stream_sdcpp_.cpp ...

Preprocessing file: C:\Users\Eric\AppData\Local\Temp\arduino_build_121923\HardwareSerial.cpp with SDCPP... 

Compiling C:\Users\Eric\AppData\Local\Temp\arduino_build_121923\HardwareSerial_sdcpp_.cpp ...

Preprocessing file: C:\Users\Eric\AppData\Local\Temp\arduino_build_121923\HLCore.cpp with SDCPP... 

Compiling C:\Users\Eric\AppData\Local\Temp\arduino_build_121923\HLCore_sdcpp_.cpp ...

Preprocessing file: C:\Users\Eric\AppData\Local\Temp\arduino_build_121923\ZUno_fp.cpp with SDCPP... 

ZUno_fp.ino:11: warning: "TRUE" redefined

In file included from C:\Users\Eric\AppData\Local\Temp\arduino_build_121923\/Arduino.h:2,

                 from C:\Users\Eric\AppData\Local\Temp\arduino_build_121923\ZUno_fp.cpp:1:

C:\Users\Eric\AppData\Local\Temp\arduino_build_121923\/ArduinoTypes.h:29:1: error: this is the location of the previous definition

ZUno_fp.ino:12: warning: "FALSE" redefined

C:\Users\Eric\AppData\Local\Temp\arduino_build_121923\/ArduinoTypes.h:30:1: error: this is the location of the previous definition



Compiling C:\Users\Eric\AppData\Local\Temp\arduino_build_121923\ZUno_fp_sdcpp_.cpp ...

ZUno_fp:274: error: no matching member function for call to 'write'



uCxx returned error code:1



exit status 1
no matching member function for call to 'write'

A Z-uno is an arduino-programmable Z-wave card that can be controlled by a Z-wave hub (HC2 for example).

I have not written any of this code, I have only modified it but i will take your suggestions about pow in consideration, Thanks=)

I've tried to check the libraries and compare to a regular Uno but I can't find any difference between Z-Uno and Arduino. I'm not really sure where to find what type of array write() expects, but it sure seems like there may be some mismatch. If I remove tBuf (the array) from Serial1.write(tBuf,len); it compiles. If I only keep tBuf i get the same error. If i write Serial1.write(tBuf[wLen + 1]) it also compiles, but I haven't yet had time to test what actually happens.

Can I make a loop that writes these array values instead?

PaulS: What the heck is a Z-Uno?

What type of array does write() expect? What type are you supplying? What type is the length argument supposed to be? What type are you supplying?

        MODE = Serial.read()-0x30;

By convention, all capital letter names are constants. Constants NEVER appear on the left of the = sign, except when initially valued.

                  User_ID = User_ID + (Serial.read()-0x30)*pow(10,(i-1));

Pow is a ridiculously expensive way to calculate 10 to the nth. Not even remotely necessary, either.

User_ID *= 10;
User_ID += Serial.read() - '0';

Why is tBuf's type unsigned char? Make it byte. The write() method may well be implemented differently for the Z-Uno, but it should always take a byte array.

The HardwareSerial class does not support the specific method. Comparing the Arduino HardwareSerial and the Z-Uno HardwareSerial, the following line is missing in the latter

        using Print::write; // pull in write(str) and write(buf, size) from Print

You can modify C:\Users\yourUserName\AppData\Local\Arduino15\packages\Z-Uno\hardware\zw8051\2.1.4\cores\zuno\HardwareSerial.h and add the above line; below the full file with modification.

#pragma once

#include "Stream.h"


class HardwareSerial: public Stream
{
    private:
        BYTE   func_vec;

    public:

        HardwareSerial(BYTE bfn);  // bfn = like ZUNO_FUNC_SERIAL1_BEGIN

      void begin();
        void begin_(word baud);
      void begin(DWORD baud);
      void end();
      virtual uint8_t available(void);
      virtual int peek(void);
      virtual uint8_t read(void);
   
           virtual void flush(void);
      virtual void write(uint8_t);

      uint8_t write(unsigned long n) {  write((uint8_t)n); return 1; }
      uint8_t write(long n) { write((uint8_t)n); return 1; }
      uint8_t write(unsigned int n) { write((uint8_t)n); return 1;}
      uint8_t write(int n) { write((uint8_t)n); return 1; }

        // added by sterretje
        using Print::write; // pull in write(str) and write(buf, size) from Print



};

extern HardwareSerial Serial;
extern HardwareSerial Serial1;
extern HardwareSerial Serial0;

That will fix the compile error; can't guarantee that it will work.

If you don't want to hack the library or it does not work, you can modify your code and use a for-loop to write single bytes.

Ok, so yesterday I got it to compile, but I couldn't access the Serial monitor. Seems to be something with the loop that the Z-Uno don't like, because if I comment everything it will download and I can access the monitor. Will try to debug later today...

I have a feeling I'll hade to go with looping through the array, but as I said I haven't had time to test it.

I just thought I’d reply and tell that I got it to read my fingerprint and I’m now ironing out some other bugs!

Thanks a lot to all that helped and especially @PaulS for the note about changing from CHAR to BYTE and for @sterretje for the answers about writing single bytes with a loop. These two changes were the last to get it to work! I will post again when (if) I get everything to work as i’d like :slight_smile: