Skip to content

Commit

Permalink
Changed comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbs38 committed Oct 17, 2017
1 parent 42b3c6b commit 91c4683
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
29 changes: 26 additions & 3 deletions yaMBSiavr.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ License: BSD-3-Clause
LICENSE:
Copyright 2017 Max Brueggemann
Copyright 2017 Max Brueggemann, www.maxbrueggemann.de
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -214,8 +214,8 @@ ISR(UART_TRANSMIT_COMPLETE_INTERRUPT)

void modbusInit(void)
{
UBRRH = (unsigned char)(UBRR>>8);
UBRRL = (unsigned char)UBRR;
UBRRH = (unsigned char)((UBRR) >> 8);
UBRRL = (unsigned char) UBRR;
UART_STATUS = (1<<U2X); //double speed mode.
#ifdef URSEL // if UBRRH and UCSRC share the same I/O location , e.g. ATmega8
UCSRC = (1<<URSEL)|(3<<UCSZ0); //Frame Size
Expand Down Expand Up @@ -404,3 +404,26 @@ uint8_t modbusExchangeBits(volatile uint8_t *ptrToInArray, uint16_t startAddress
return 0;
}
}

/* @brief: Handles function code "report slave id".
*
* Arguments: - in: MUST BE NULL-TERMINATED and shorter than MaxFrameIndex-4
* (without NULL-Byte, the NULL-Byte is not transmitted).
* Pointer to the user's data array containing user specific
* information, typically a string (hence the null termination).
* The last byte should (according to spec) contain the 'run indication"
* (running: 0xFF, not running: 0x00). This seems to be originating
* from PLC terminology and is often omitted nowadays.
*
* @example: char myDeviceDescription[] = {"modbus capable device that is always running V1.0\0xFF\0x00"}
* modbusSendSlaveID(myDeviceDescription);
*/
void modbusSendSlaveID(char *in) {
uint8_t c = 0;
for (;(c<(MaxFrameIndex-2)) && in[c]!=0;c++)
{
rxbuffer[c+3]=in[c];
}
rxbuffer[2]=c+1; //byte count
modbusSendMessage(c+2);
}
16 changes: 15 additions & 1 deletion yaMBSiavr.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ License: BSD-3-Clause
LICENSE:
Copyright 2017 Max Brueggemann
Copyright 2017 Max Brueggemann, www.maxbrueggemann.de
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -332,3 +332,17 @@ extern uint8_t modbusExchangeBits(volatile uint8_t *ptrToInArray, uint16_t start
*/
extern uint8_t modbusExchangeRegisters(volatile uint16_t *ptrToInArray, uint16_t startAddress, uint16_t size);

/* @brief: Handles function code "report slave id".
*
* Arguments: - in: MUST BE NULL-TERMINATED and shorter than MaxFrameIndex-4
* (without NULL-Byte, the NULL-Byte is not transmitted).
* Pointer to the user's data array containing user specific
* information, typically a string (hence the null termination).
* The last byte should (according to spec) contain the 'run indication"
* (running: 0xFF, not running: 0x00). This seems to be originating
* from PLC terminology and is often omitted nowadays.
*
* @example: char myDeviceDescription[] = {"modbus capable device that is always running V1.0\0xFF\0x00"}
* modbusSendSlaveID(myDeviceDescription);
*/
extern void modbusSendSlaveID(char *in);

0 comments on commit 91c4683

Please sign in to comment.