def sendphoto(byte):
	global count
	i, j, k = 0, 0, 0

	with open("/home/pi/log/communicationlog.txt","w")as f:
		f.write(str(byte))

	for i in range(0,len(byte),64):
		data = IM920.IMSend(byte[i:i+64])
		cng = IM920.Reception()
		for j in range(5):
			print(count, j)
			if(cng == ""):
				data = IM920.IMSend(byte[i:i+64])
				cng = IM920.Reception()
			else:
				time.sleep(0.1)
				count+=1
				break
		#print(j)
		if j == 4:
			break

		#print(i,'/',len(byte))
		amari=len(byte)-i

	amari=len(byte)-i
	IM920.IMSend(byte[i:i+amari])
	data=IM920.IMSend(byte[i:i+amari])
	cng=IM920.Reception()
	for k in range(5):
		print(count,k)
		if(cng==""):
			data=IM920.IMSend(byte[i:i+amari])
			cng=IM920.Reception()
		else:
			break

	#print(amari,'/',64)
	#print(str(byte[i:i+amari]))

	IM920.Send("MFend")
	time.sleep(1)
	IM920.Send("MFend")
	time.sleep(1)
	IM920.Send("MFend")
x = 0
amari = 0
img = cv2.imread("/home/pi/git/kimuralab/SensorModuleTest/Camera/photo80.jpg",
                 0)
byte = convertIMG2BYTES.IMGtoBYTES(img)
with open("soushinlog.txt", "w") as f:
    f.write(str(byte))
#print(byte[0:100])

for i in range(0, len(byte), 64):
    #if i%640==0:
    #print("sleep")
    #time.sleep(0.5)
    if i == 3840:
        time.sleep(3)
    data = IM920.IMSend(byte[i:i + 64])
    cng = IM920.Reception()
    if (cng == ""):
        data = IM920.IMSend(byte[i:i + 64])
        cng = IM920.Reception()
    time.sleep(0.1)
    count += 1
    print(count, data)

    print(i, '/', len(byte))
    #	print(str(byte[i:i+63]))
    amari = len(byte) - i
#	print(str(amari))
amari = len(byte) - i
IM920.IMSend(byte[i:i + amari])
print(amari, '/', 64)