# LoadError: UndefVarError: nb\_available not defined

**URL:** https://discourse.julialang.org/t/loaderror-undefvarerror-nb-available-not-defined/58954
**Category:** General Usage
**Tags:** question, package
**Created:** [April 9, 2021, 11:23pm UTC](https://discourse.julialang.org/t/loaderror-undefvarerror-nb-available-not-defined/58954 "2021-04-09T23:23:47Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![SudhakarKuma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sudhakarkuma/32/23800_2.png) [@SudhakarKuma](https://discourse.julialang.org/u/SudhakarKuma)
#### Post date: [April 9, 2021, 11:23pm UTC](https://discourse.julialang.org/t/loaderror-undefvarerror-nb-available-not-defined/58954/1 "2021-04-09T23:23:47Z")

</div>

Hello everyone! I have a function (as given below) that was working for **Julia 0.4.5**.

```julia
function analogRead(file_des::SerialPorts.SerialPort , pin_no::Int64)
  str = "A"*string(Char(48+pin_no)) #"An" for analog value on pin n
  write(file_des,str)
  sleep(0.1) # Delay next step by 100 milliseconds
  n = nb_available(file_des) # Get number of bytes in input buffer
  s = read(file_des,n) # Read n bytes from SerialPort
  k = parse(Int,s) # Convert String to integer
  return k # Return the integer
end

```

Now, I have **Julia 1.6.0** on my machine. As expected, the above-mentioned function is not working on this new Julia. While running this function on **Julia 1.6.0** , we get an error, as shown below.

> LoadError: UndefVarError: nb\_available not defined

I came to know that **nb\_available** no longer exists in **Base** , as given on [Base.nb\_available is deprecated in Julia 0.7 and gone in 1.0 · Issue #53 · JuliaIO/BufferedStreams.jl · GitHub](https://github.com/BioJulia/BufferedStreams.jl/issues/53). On [LibSerialPort.jl – access serial ports · LibSerialPort.jl](https://juliahub.com/docs/LibSerialPort/2VCGH/0.5.0/), I found that one can use  
**Base.bytesavailable** , which returns the number of bytes waiting in the input buffer. Thus, I modified my function as given below:

```julia
function analogRead(file_des::SerialPorts.SerialPort , pin_no::Int64)
  str = "A"*string(Char(48+pin_no)) #"An" for analog value on pin n
  write(file_des,str)
  sleep(0.1) # Delay next step by 100 milliseconds
  n = bytesavailable(file_des) # Get number of bytes in input buffer
  s = read(file_des,n) # Read n bytes from SerialPort
  k = parse(Int,s) # Convert String to integer
  return k # Return the integer
end

```

However, it didn’t work, and upon executing this function in my Julia code, it throws an error as shown below:

> LoadError: ArgumentError: invalid base 10 digit '`' in "`\x02"

Could you please help me with how to use **bytesavailable** in the above-mentioned function on Julia 1.6.0?

Thanking you in anticipation,

Regards,  
Sudhakar

---

<div class="post-metadata">

### Author: ![SudhakarKuma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sudhakarkuma/32/23800_2.png) [@SudhakarKuma](https://discourse.julialang.org/u/SudhakarKuma)
#### Post date: [April 10, 2021, 2:22pm UTC](https://discourse.julialang.org/t/loaderror-undefvarerror-nb-available-not-defined/58954/2 "2021-04-10T14:22:39Z")

</div>

I got this working, as given in [Converting string of bytes to integer - #4 by SudhakarKuma](https://discourse.julialang.org/t/converting-string-of-bytes-to-integer/58962/4).

Thanks, @Benny.
