<commit_before>#include "modlib.h"

uint8_t MODBUSReadMaskBit( uint8_t *Mask, uint16_t MaskLength, uint16_t Bit )
{
	//Return nth bit from uint8_t array
	//When 255 value is returned, an error occured

	if ( ( Bit >> 3 ) >= MaskLength ) return 255;
	return ( Mask[Bit >> 3] & ( 1 << ( Bit % 8 ) ) ) >> ( Bit % 8 );
}

uint8_t MODBUSWriteMaskBit( uint8_t *Mask, uint16_t MaskLength, uint16_t Bit, uint8_t Value )
{
	//Write nth bit in uint8_t array
	//When 255 value is returned, an error occured

	if ( ( Bit >> 3 ) >= MaskLength ) return 255;
	Mask[Bit >> 3] |= ( 1 << ( Bit % 8 ) ) * Value;
	return 0;
}

uint16_t MODBUSSwapEndian( uint16_t Data )
{
    //Change big-endian to little-endian and vice versa

    uint8_t Swap;

	//Create 2 bytes long union
    union Conversion
    {
        uint16_t Data;
        uint8_t Bytes[2];
    } Conversion;<commit_msg>Fix MODBUSWriteMaskBit function<commit_after>#include "modlib.h"

uint8_t MODBUSReadMaskBit( uint8_t *Mask, uint16_t MaskLength, uint16_t Bit )
{
	//Return nth bit from uint8_t array
	//When 255 value is returned, an error occured

	if ( ( Bit >> 3 ) >= MaskLength ) return 255;
	return ( Mask[Bit >> 3] & ( 1 << ( Bit % 8 ) ) ) >> ( Bit % 8 );
}

uint8_t MODBUSWriteMaskBit( uint8_t *Mask, uint16_t MaskLength, uint16_t Bit, uint8_t Value )
{
	//Write nth bit in uint8_t array
	//When 255 value is returned, an error occured

	if ( ( Bit >> 3 ) >= MaskLength ) return 255;
	if ( Value )
		Mask[Bit >> 3] |= ( 1 << ( Bit % 8 ) );
	else
		Mask[Bit >> 3] &= ~( 1 << ( Bit % 8 ) );
	return 0;
}

uint16_t MODBUSSwapEndian( uint16_t Data )
{
    //Change big-endian to little-endian and vice versa

    uint8_t Swap;

	//Create 2 bytes long union
    union Conversion
    {
        uint16_t Data;
        uint8_t Bytes[2];
    } Conversion;
{'fraction_non_alphanumeric': 0.12347052280311457, 'fraction_numerical': 0.053948832035595105, 'mean_word_length': 2.997777777777778, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 29, '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': '2025033', 'n_tokens_mistral': 745, 'n_tokens_neox': 666, 'n_words': 210}