#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <errno.h>
#include <time.h>
#include "modbus/modbus.h"
Go to the source code of this file.
|
void | closeConnection () |
|
void | delay (int millis) |
|
void | delayMicroseconds (int micros) |
|
int | isValidPin (int pinNum) |
|
int | connectArduino (char *port, int baudRate, int id) |
|
void | pinMode (uint8_t pinNum, uint8_t mode) |
|
void | digitalWrite (uint8_t pinNum, uint8_t input) |
|
int | digitalRead (uint8_t pinNum) |
|
void | analogWrite (uint8_t pinNum, uint16_t input) |
|
int | analogRead (uint16_t pinNum) |
|
void | servoAttach (uint16_t pinNum) |
|
void | servoDetach (uint16_t pinNum) |
|
void | servoWrite (uint16_t pinNum, uint16_t input) |
|
int | servoRead (uint16_t pinNum) |
|
void | wireBegin () |
|
void | wireEnd () |
|
void | wireSetClock (uint32_t) |
|
void | wireWrite (uint8_t addr, uint8_t reg, uint8_t num_bytes, uint8_t *data) |
|
uint8_t * | wireRead (uint8_t addr, uint8_t reg, int num_bytes) |
|
void | spiBegin () |
|
uint8_t * | spiTransferBuf (int CS_pin, uint8_t *buf, uint8_t length) |
|
void | spiSettings (uint32_t speed, uint8_t order, uint8_t mode) |
|
void | spiEnd () |
|
void | transmitRegisters (uint8_t fn_code, uint8_t argc, uint8_t *argv) |
|
◆ ANALOGREAD
◆ ANALOGREFERENCE
#define ANALOGREFERENCE 4 |
◆ ANALOGWRITE
◆ DIGITALREAD
◆ DIGITALWRITE
◆ HIGH
◆ IDLE
◆ INPUT
◆ LOW
◆ LSBFIRST
◆ MSBFIRST
◆ OUTPUT
◆ PINMODE
◆ SERVOATTACH
◆ SERVODETACH
◆ SERVOREAD
◆ SERVOWRITE
◆ SPI_MODE0
◆ SPI_MODE1
◆ SPI_MODE2
◆ SPI_MODE3
◆ SPIBEGIN
◆ SPIEND
◆ SPISETTINGS
◆ SPITRANSFER
◆ WIREBEGIN
◆ WIRECLOCK
◆ WIREEND
◆ WIREREAD
◆ WIREWRITE
◆ analogRead()
int analogRead |
( |
uint16_t |
pinNum | ) |
|
Reads the value of an analog pin
- Parameters
-
- Returns
- (int) value read from pin
Reads the value of an analog pin
- Parameters
-
(uint8_t) | address |
(uint8_t) | register |
(uint8_t) | number of bytes to read |
- Returns
- (uint8_t*) pointer to the data that was read
◆ analogWrite()
void analogWrite |
( |
uint8_t |
pinNum, |
|
|
uint16_t |
input |
|
) |
| |
Writes an analog value to a pin
- Parameters
-
(int) | pin number |
(int) | value to be written |
- Returns
- void
Writes an analog value to a pin
- Parameters
-
(uint8_t) | pin number |
(uint16_t) | value to write |
- Returns
- (void)
◆ closeConnection()
disconnect modbus connection if the program does not have an infinite loop
- Parameters
-
- Returns
- void
◆ connectArduino()
int connectArduino |
( |
char * |
port, |
|
|
int |
baudRate, |
|
|
int |
id |
|
) |
| |
Initiates connection between machine and Arduino
- Parameters
-
(char*) | path to port |
(int) | baud rate (9600 default) |
(int) | slave id |
- Returns
- (int) 1 if connection is successful, 0 if failure
Start serial connection using specified port and baud rate
- Parameters
-
(char*) | path to the port on which Leonardo is connected |
(int) | baud rate |
(int) | slave id for Leonardo |
- Returns
- (int) 1 if successful, 0 if unsuccessful
◆ delay()
Causes the system to delay a number of miliseconds
- Parameters
-
- Returns
- void
◆ delayMicroseconds()
void delayMicroseconds |
( |
int |
micros | ) |
|
◆ digitalRead()
int digitalRead |
( |
uint8_t |
pinNum | ) |
|
Reads the value of a digital pin
- Parameters
-
- Returns
- (int) value read from pin
Reads the value of a digital pin
- Parameters
-
- Returns
- (int) value
◆ digitalWrite()
void digitalWrite |
( |
uint8_t |
pinNum, |
|
|
uint8_t |
input |
|
) |
| |
Writes a digital value (1 or 0) to a pin
- Parameters
-
(int) | pin number |
(int) | value to be written |
- Returns
- void
Writes a HIGH or LOW value to a digital pin
- Parameters
-
(uint8_t) | pin number |
(uint8_t) | input, should be 1 or 0 |
- Returns
- (void)
◆ isValidPin()
int isValidPin |
( |
int |
pinNum | ) |
|
Determines if a given pin number is valid (valid pins are 1-30)
- Parameters
-
- Returns
- (int) 1 if valid, 0 if invalid
Checks if a pin number is valid The leonardo has pins 1-30
- Parameters
-
- Returns
- (int) 1 if pin is valid, 0 if invalid
◆ pinMode()
void pinMode |
( |
uint8_t |
pinNum, |
|
|
uint8_t |
mode |
|
) |
| |
Sets the pin mode of a pin on the Arduino
- Parameters
-
(int) | pin number |
(int) | mode to set pin to |
- Returns
- void
Sets pin mode
- Parameters
-
(uint8_t) | pin number |
(uint8_t) | pin mode |
- Returns
- (void)
◆ servoAttach()
void servoAttach |
( |
uint16_t |
pinNum | ) |
|
Attaches a servo to a pin
- Parameters
-
- Returns
- void
Attach servo to a pin
- Parameters
-
- Returns
- (void)
◆ servoDetach()
void servoDetach |
( |
uint16_t |
pinNum | ) |
|
Detaches a servo from a pin
- Parameters
-
- Returns
- void
Detach servo from a pin
- Parameters
-
- Returns
- (void)
◆ servoRead()
int servoRead |
( |
uint16_t |
pinNum | ) |
|
Reads the value last written to a servo
- Parameters
-
- Returns
- (int) angle value last written
Reads the last value written to a servo
- Parameters
-
- Returns
- (int) the last value written to the servo
◆ servoWrite()
void servoWrite |
( |
uint16_t |
pinNum, |
|
|
uint16_t |
input |
|
) |
| |
Writes an angle value to a servo
- Parameters
-
(int) | pin number |
(int) | angle value to write |
- Returns
- void
Write values to a servo assigned pin
- Parameters
-
(uint16_t) | pin number |
(uint16_t) | angle value to be written |
- Returns
- (void)
◆ spiBegin()
Begins SPI communication with default settings (4 Mbps, MSBFIRST, SPI_MODE0)
- Returns
- (void)
◆ spiEnd()
End SPI communication
- Returns
- (void)
◆ spiSettings()
void spiSettings |
( |
uint32_t |
speed, |
|
|
uint8_t |
order, |
|
|
uint8_t |
mode |
|
) |
| |
Set specific SPI settings such as communication speed, bit order, and mode
- Parameters
-
(uint32_t) | Communication speed |
(uint8_t) | bit order (MSBFIRST or LSBFIRST) |
(uint8_t) | data mode (SPI_MODE0, SPI_MODE1, SPI_MODE2, or SPI_MODE3) |
- Returns
- (void)
◆ spiTransferBuf()
uint8_t* spiTransferBuf |
( |
int |
CS_pin, |
|
|
uint8_t * |
buf, |
|
|
uint8_t |
length |
|
) |
| |
Transfer an array of bytes over SPI
- Parameters
-
(int) | Chip Select pin number |
(uint8_t*) | Array of bytes to transfer over MOSI |
(uint8_t) | Array length |
- Returns
- (uint8_t*) Array of bytes sent back over MISO
◆ transmitRegisters()
void transmitRegisters |
( |
uint8_t |
fn_code, |
|
|
uint8_t |
argc, |
|
|
uint8_t * |
argv |
|
) |
| |
Send bytes over Modmata. For use in custom Modmata functions
- Returns
- (void)
◆ wireBegin()
Begins an I2C connection
- Returns
- (void)
◆ wireEnd()
Terminates an I2C connection
- Returns
- (void)
◆ wireRead()
uint8_t* wireRead |
( |
uint8_t |
addr, |
|
|
uint8_t |
reg, |
|
|
int |
num_bytes |
|
) |
| |
Reads data from an I2C connection
- Parameters
-
(uint8_t) | address byte |
(uint8_t) | register byte |
(uint8_t) | number of bytes to read |
- Returns
- (uint8_t*) array of bytes that were read
Reads data from an I2C connection
- Parameters
-
(uint8_t) | address |
(uint8_t) | register |
(uint8_t) | number of bytes to read |
- Returns
- (uint8_t*) pointer to the data that was read
◆ wireSetClock()
void wireSetClock |
( |
uint32_t |
clock_speed | ) |
|
Sets I2C clock speed
- Parameters
-
- Returns
- (void)
◆ wireWrite()
void wireWrite |
( |
uint8_t |
addr, |
|
|
uint8_t |
reg, |
|
|
uint8_t |
num_bytes, |
|
|
uint8_t * |
data |
|
) |
| |
Writes data over an I2C connection
- Parameters
-
(uint8_t) | address byte |
(uint8_t) | register byte |
(uint8_t) | number of bytes to be written following the address and register |
(uint8_t*) | array of bytes being written |
- Returns
- (void)
Writes data over an I2C connection
- Parameters
-
(uint8_t) | address |
(uint8_t) | register |
(uint8_t) | number of bytes to be written |
(uint8_t) | data being written |
- Returns
- (void)