Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serial:start() not accessible #14

Closed
quantumproducer opened this issue Mar 12, 2017 · 6 comments
Closed

serial:start() not accessible #14

quantumproducer opened this issue Mar 12, 2017 · 6 comments

Comments

@quantumproducer
Copy link

^C~/code/erlang-serial:.which erl
/usr/local/bin/erl

~/code/erlang-serial:.make
gcc   -g    -c -o c_src/serial.o c_src/serial.c
c_src/serial.c:273:16: warning: passing 'char [2]' to parameter of type 'unsigned char *'
      converts between pointers to integer types with different sign [-Wpointer-sign]
  set_tbh_size(header_buf, buffsize);
               ^~~~~~~~~~
c_src/serial.c:253:33: note: passing argument to parameter 'buf' here
void set_tbh_size(unsigned char buf[], int size)
                                ^
c_src/serial.c:611:22: warning: passing 'unsigned char *' to parameter of type
      'const char *' converts between pointers to integer types with different sign
      [-Wpointer-sign]
                    strcpy(ttyname,&buf[HEADERSIZE]);
                    ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/secure/_string.h:83:33: note: expanded from macro 'strcpy'
  __builtin___strcpy_chk (dest, src, __darwin_obsz (dest))
                                ^~~
c_src/serial.c:646:35: warning: passing 'unsigned char *' to parameter of type
      'const char *' converts between pointers to integer types with different sign
      [-Wpointer-sign]
                      in_speed = get_speed(atoi(&buf[HEADERSIZE]));
                                                ^~~~~~~~~~~~~~~~
/usr/include/stdlib.h:132:23: note: passing argument to parameter here
int      atoi(const char *);
                          ^
c_src/serial.c:656:36: warning: passing 'unsigned char *' to parameter of type
      'const char *' converts between pointers to integer types with different sign
      [-Wpointer-sign]
                      out_speed = get_speed(atoi(&buf[off]));
                                                 ^~~~~~~~~
/usr/include/stdlib.h:132:23: note: passing argument to parameter here
int      atoi(const char *);
                          ^
4 warnings generated.
mkdir -p priv/bin
mkdir -p priv/bin
gcc -o priv/bin/serial  c_src/serial.o
mkdir -p ebin
erlc -o ebin src/serial.erl
erlc -o ebin src/slip.erl
~/code/erlang-serial:.DESTDIR=/usr/local/bin make install
install -d /usr/local/bin/erlang/lib/serial-1.1/ebin
install -d /usr/local/bin/erlang/lib/serial-1.1/priv/bin
install -d /usr/local/bin/erlang/lib/serial-1.1/src
install -m 644 ebin/* /usr/local/bin/erlang/lib/serial-1.1/ebin
install -m 755 priv/bin/* /usr/local/bin/erlang/lib/serial-1.1/priv/bin
install -m 644 src/* /usr/local/bin/erlang/lib/serial-1.1/src

~/code/erlang-serial:.erl
Erlang/OTP 19 [erts-8.2] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Eshell V8.2  (abort with ^G)
1> serial:start().
** exception error: undefined function serial:start/0
2>

@tonyg
Copy link
Owner

tonyg commented Mar 13, 2017

I think if you invoke erlang with erl -pa ebin instead of just erl, you should be able to get serial:start() to work.

@tonyg tonyg closed this as completed Mar 13, 2017
@quantumproducer
Copy link
Author

@tonyg I thought that by installing the source files into my erlang lib folder, such a step becomes unnecessary because they are loaded everytime?

@tonyg
Copy link
Owner

tonyg commented Mar 14, 2017

Oh! Good point! I missed the "install" step in your transcript! Sorry. I'll take another look.

@tonyg tonyg reopened this Mar 14, 2017
@tonyg
Copy link
Owner

tonyg commented Mar 14, 2017

I think Erlang by default just has /usr/lib/erlang/lib as its library directory. Perhaps either install with make DESTDIR=/usr/lib install, or run with ERL_LIBS=/usr/local/bin/erlang/lib erl. See the section on the "code path" at http://erlang.org/doc/man/code.html for more information.

@tonyg tonyg closed this as completed Mar 14, 2017
@tonyg
Copy link
Owner

tonyg commented Mar 14, 2017

Oh, I see you probably have OTPROOT as /usr/local, so for you perhaps

make DESTDIR=/usr/local/lib install

is what's required.

@quantumproducer
Copy link
Author

Yes, that gives me a Pid, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants