Giter VIP home page Giter VIP logo

Comments (6)

babca avatar babca commented on August 15, 2024 2

I suggest to change nibble2octet() function to:

def nibble2octet(addressLen):
    return int((addressLen + 1) / 2)

from python-gsmmodem.

tomchy avatar tomchy commented on August 15, 2024

Back in the faucamp/python-gsmmodem repository instead of nibble2octet(o) there were two pieces of code doing this operation:

addressLen = int(math.ceil(addressLen / 2.0))

and:

if addressLen % 2:
    addressLen = int(addressLen / 2) + 1
else:
    addressLen = int(addressLen / 2)

There are no more occurrences of nibble2octet, so I think that confirms that this fix doesn't break anything else 🙂

from python-gsmmodem.

9dogs avatar 9dogs commented on August 15, 2024

Thank you! I'm making pull request then.

from python-gsmmodem.

lcnittl avatar lcnittl commented on August 15, 2024

Just a question: Shouldn't addressLen = int((addressLen + 1) / 2) give the same values, just without the need of an if statement or a function from math?

from python-gsmmodem.

babca avatar babca commented on August 15, 2024

The faucamp@df20a9a fix from 2014 was originally part of the codebase until I merged @paolo-losi branch.

The nibble2octet() function was introduced by paolo-losi@0076b9d to fix something. I think he wanted to use the same piece of code on both places and he forgot to use int() in his new function.

from python-gsmmodem.

babca avatar babca commented on August 15, 2024

quick test, all three blocks give the same values:

0
1
1
2
2
3
3
import math

def testblock1(addressLen):
	if addressLen % 2:
	    addressLen = int(addressLen / 2) + 1
	else:
	    addressLen = int(addressLen / 2)
	print (addressLen)

testblock1(0)
testblock1(1)
testblock1(2)
testblock1(3)
testblock1(4)
testblock1(5)
testblock1(6)

def testblock2(addressLen):
	addressLen = int(math.ceil(addressLen / 2.0))
	print (addressLen)

testblock2(0)
testblock2(1)
testblock2(2)
testblock2(3)
testblock2(4)
testblock2(5)
testblock2(6)

def testblock3(addressLen):
	addressLen = int((addressLen + 1) / 2)
	print (addressLen)

testblock3(0)
testblock3(1)
testblock3(2)
testblock3(3)
testblock3(4)
testblock3(5)
testblock3(6)

from python-gsmmodem.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.