Hi’
So I am new to serial, and hex and all that but Ive spent the last week+ trying to figure out how to use this serial to lanc adaptor to trigger my sony camera… I think Im close, but I may be going at it the absolute wrong way about it.
I have confirmed the serial port COM3 to be correct by using the software that the company that makes the adapter makes. I am also using all the same settings on the Dats parameters themselves… If anyone with experience in serial can just take a peek here and tell me what Im doing wrong…
Also… this may be a clue: If I use their software, connect to the camera and then close it and open up the touch serial dat it streams the serial from the camera… but not if I didnt come straight from their software with the connection established… One possible issue would be that I am not connected fully when sending the hex?
b\x18:
seems to be the ascii byte for 0001 1000
and then the hex ‘3A’ (rec) but Ive also tried ‘33’ (start/stop)
But Im pretty sure all I need to send is the (2 byte) message “1833” … but its a bitch to figure out how / where I am going wrong.
Serial lanc adaptor used
Lanc command info
After alot of research on python hex conversion jazz, this is the script I am now attempting to use on a serial dat :
import struct
byte0 = '00011000'
my_hexdata = "33"
scale = 16 ## equals to hexadecimal
num_of_bits = 8
binaryhex = bin(int(my_hexdata, scale))[2:].zfill(num_of_bits)
fullbinary = str(byte0)+str(binaryhex)
print(fullbinary)
bytez = struct.pack('!H', int(fullbinary, 2))
print(bytez)
op('serial1').sendBytes(bytez)
which simply does not work…
They sent me an example script written in VB.net:
[code]Public Sub Initial_Port()
Try
myport.Close()
With myport
.PortName = CommPortName
.BaudRate = 9600
.DataBits = 8
.StopBits = IO.Ports.StopBits.One
.Parity = IO.Ports.Parity.None
.ReceivedBytesThreshold = 4
.Handshake = IO.Ports.Handshake.None
End With
If myport.IsOpen() Then
Else
myport.Open()
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Public Sub ResetInterface()
'Turn off echo so the send codes to not return
send_car("ATE0")
Thread.Sleep(10)
'Return data only when the status changes
send_car("ATC1")
Thread.Sleep(10)
'sends the commands 15 times
send_car("ATRe")
Thread.Sleep(10)
'removed B0 + B1 duplication
send_car("ATD0")
Thread.Sleep(10)
'Send VTR stop
bflag = 1
send_car("1830")
End Sub
Public Sub send_car(ByVal car As String)
Try
myport.Write(car + Chr(13))
Catch ex As Exception
End Try
End Sub
Private Sub bRecStartStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bRecStartStop.Click
send_car("1833")
End Sub
[/code]