<commit_before>#include "../modlib.h"
#include "../parser.h"
#include "mtypes.h"

#include "mdiscreteinputs.h"

//Use external master configuration
extern MODBUSMasterStatus MODBUSMaster;

uint8_t MODBUSBuildRequest02( uint8_t Address, uint16_t FirstCoil, uint16_t CoilCount )
{
	//Build request02 frame, to send it so slave
	//Read multiple discrete inputs

	//Set frame length
	uint8_t FrameLength = 8;

	//Set output frame length to 0 (in case of interrupts)
	MODBUSMaster.Request.Length = 0;

	//Allocate memory for frame builder
	union MODBUSParser *Builder = (union MODBUSParser *) malloc( FrameLength );

	//Reallocate memory for final frame
	MODBUSMaster.Request.Frame = (uint8_t *) realloc( MODBUSMaster.Request.Frame, FrameLength );

	( *Builder ).Base.Address = Address;
	( *Builder ).Base.Function = 1;
	( *Builder ).Request02.FirstInput = MODBUSSwapEndian( FirstCoil );
	( *Builder ).Request02.InputCount = MODBUSSwapEndian( CoilCount );<commit_msg>Fix function code<commit_after>#include "../modlib.h"
#include "../parser.h"
#include "mtypes.h"

#include "mdiscreteinputs.h"

//Use external master configuration
extern MODBUSMasterStatus MODBUSMaster;

uint8_t MODBUSBuildRequest02( uint8_t Address, uint16_t FirstCoil, uint16_t CoilCount )
{
	//Build request02 frame, to send it so slave
	//Read multiple discrete inputs

	//Set frame length
	uint8_t FrameLength = 8;

	//Set output frame length to 0 (in case of interrupts)
	MODBUSMaster.Request.Length = 0;

	//Allocate memory for frame builder
	union MODBUSParser *Builder = (union MODBUSParser *) malloc( FrameLength );

	//Reallocate memory for final frame
	MODBUSMaster.Request.Frame = (uint8_t *) realloc( MODBUSMaster.Request.Frame, FrameLength );

	( *Builder ).Base.Address = Address;
	( *Builder ).Base.Function = 2;
	( *Builder ).Request02.FirstInput = MODBUSSwapEndian( FirstCoil );
	( *Builder ).Request02.InputCount = MODBUSSwapEndian( CoilCount );
{'fraction_non_alphanumeric': 0.10995850622406639, 'fraction_numerical': 0.02074688796680498, 'mean_word_length': 4.6902654867256635, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7115925', 'n_tokens_mistral': 645, 'n_tokens_neox': 604, 'n_words': 180}