Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

README cleanup

  • Loading branch information...
commit 322e214f98c986ea47082ff0237d2f39124912d0 1 parent 50fdf43
@msantos authored
View
20 README.md
@@ -124,10 +124,10 @@ converting binaries using serctl:termios/1) include their definition:
Sets the terminal attributes of the serial device.
- _Warning: the contents of Termios are passed directly to
- tcsettr(3). If the system tcsettr(3) does not check if the
- structure is valid, it may cause the library to crash, causing
- the Erlang VM to crash._
+ Warning: the contents of Termios are passed directly to
+ tcsettr(3). If the system tcsettr(3) does not perform any
+ validation of the structure, it's possible the Erlang VM will
+ crash.
serctl:cfsetispeed(Termios, Speed) -> Termios1
@@ -182,8 +182,8 @@ structure and do not have side effects when used with the record format
(when binaries are used as arguments, they are first converted to record
format based on a runtime platform check).
-To change the serial device, the attributes must
-be written out using serctl:tcsetattr/3.
+To modify the serial device, the attributes must be written out using
+serctl:tcsetattr/3.
serctl:flow(Termios) -> true | false
serctl:flow(Termios, Bool) -> #termios{}
@@ -266,7 +266,7 @@ be written out using serctl:tcsetattr/3.
% Open the serial device
{ok, FD} = serctl:open("/dev/ttyUSB0"),
-
+
% Set the terminal attributes to:
% raw, no hardware flow control, 9600
Termios = lists:foldl(
@@ -278,12 +278,12 @@ be written out using serctl:tcsetattr/3.
fun(N) -> serctl:ospeed(N, b9600) end
]
),
-
+
ok = serctl:tcsetattr(FD, tcsanow, Termios),
-
+
% Write 1 byte to the arduino
ok = serctl:write(FD, <<1:8>>),
-
+
% Read 2 bytes from the arduino (little-endian integer)
{ok, <<Data:2/little-integer-unit:8>>} = serctl:read(FD, 2).
View
12 c_src/serctl.c
@@ -1,21 +1,21 @@
/* Copyright (c) 2011-2012, Michael Santos <michael.santos@gmail.com>
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -343,7 +343,7 @@ nif_constants(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
static ERL_NIF_TERM
nif_constant(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
{
- char buf[255];
+ char buf[255] = {0};
const struct SERCTL_DEF *p = NULL;
View
10 c_src/serctl.h
@@ -1,22 +1,22 @@
/*
* Copyright (c) 2011-2012, Michael Santos <michael.santos@gmail.com>
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
View
2  examples/strobe/strobe.pde
@@ -55,7 +55,7 @@ void loop() {
inb -= '0';
#endif /* DEBUG */
- for (val = 0; val <= LPIN - FPIN; val++)
+ for (val = 0; val <= LPIN - FPIN; val++)
digitalWrite(val + FPIN, ( (inb & (1 << val)) ? HIGH : LOW));
}
}
View
2  src/serctl.erl
@@ -294,7 +294,7 @@ baud(Speed) when is_integer(Speed) ->
%% Linux:
%% #define NCCS 32
%% struct termios
-%% {
+%% {
%% tcflag_t c_iflag; /* input mode flags */
%% tcflag_t c_oflag; /* output mode flags */
%% tcflag_t c_cflag; /* control mode flags */
Please sign in to comment.
Something went wrong with that request. Please try again.