serial port speed - serial-port
I try to connect a device to my windows CE device, through the serial port using ppp and I discovered that the other device (arm-linux) changes its port speed continuously.
It should be 38400 baud but it's not constant.
The speed should be constant?
What I'm doing to chek it is
stty -F /dev/ttyS3
and the output
speed 9600 baud;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
lnext = ^V; flush = ^O; min = 1; time = 0;
-brkint -imaxbel
-echo
[some time later]
speed 38400 baud;
[some time later]
speed 0 baud;
In the windows CE device I get:
Error: 679 (Incorrect connection profile)
The point is that the speed should be constant in my linux device? or should I check other thinks.
Related
How do you simulate packet drop caused by UDP flooding in Mininet?
Just to be clear, I am not interested in adding a constant packet drop on a link (as described by this Stack Overflow question). I want to observe packet drop taking place naturally in the network due to congestion. The intention of my project is to observe the packet drop and delay taking place in a network (preferably an SDN) by varying the qdisc buffer size on the router node. I have a basic topology of three nodes h1, h2 and h3 connected to a router r. I am conducting my experiment along the lines of this tutorial taking place inside a custom environment. My code is shown below: DELAY='110ms' # r--h3 link BBR=False import sys import shelve import os import re import numpy as np import matplotlib.pyplot as plt from mininet.term import makeTerm from mininet.net import Mininet from mininet.node import Node, OVSKernelSwitch, Controller, RemoteController from mininet.cli import CLI from mininet.link import TCLink from mininet.topo import Topo from mininet.log import setLogLevel, info import time class LinuxRouter( Node ): "A Node with IP forwarding enabled." def config( self, **params ): super( LinuxRouter, self).config( **params ) # Enable forwarding on the router info ('enabling forwarding on ', self) self.cmd( 'sysctl net.ipv4.ip_forward=1' ) def terminate( self ): self.cmd( 'sysctl net.ipv4.ip_forward=0' ) super( LinuxRouter, self ).terminate() class RTopo(Topo): def build(self, **_opts): defaultIP = '10.0.1.1/24' # IP address for r0-eth1 r = self.addNode( 'r', cls=LinuxRouter) # , ip=defaultIP ) h1 = self.addHost( 'h1', ip='10.0.1.10/24', defaultRoute='via 10.0.1.1' ) h2 = self.addHost( 'h2', ip='10.0.2.10/24', defaultRoute='via 10.0.2.1' ) h3 = self.addHost( 'h3', ip='10.0.3.10/24', defaultRoute='via 10.0.3.1' ) self.addLink( h1, r, intfName1 = 'h1-eth', intfName2 = 'r-eth1', bw=80, params2 = {'ip' : '10.0.1.1/24'}) self.addLink( h2, r, intfName1 = 'h2-eth', intfName2 = 'r-eth2', bw=80, params2 = {'ip' : '10.0.2.1/24'}) . self.addLink( h3, r, intfName1 = 'h3-eth', intfName2 = 'r-eth3', params2 = {'ip' : '10.0.3.1/24'}, delay=DELAY, queue=QUEUE) # apparently queue is IGNORED here. def main(): rtopo = RTopo() net = Mininet(topo = rtopo, link=TCLink, #switch = OVSKernelSwitch, # ~ controller = RemoteController, autoSetMacs = True # --mac ) net.start() r = net['r'] r.cmd('ip route list'); # r's IPv4 addresses are set here, not above. r.cmd('ifconfig r-eth1 10.0.1.1/24') r.cmd('ifconfig r-eth2 10.0.2.1/24') r.cmd('ifconfig r-eth3 10.0.3.1/24') r.cmd('sysctl net.ipv4.ip_forward=1') h1 = net['h1'] h2 = net['h2'] h3 = net['h3'] h3.cmdPrint("iperf -s -u -i 1 &") r.cmdPrint("tc qdisc del dev r-eth3 root") bsizes = [] bsizes.extend(["1000mb","10mb","5mb","1mb","200kb"]) bsizes.extend(["100kb","50kb","10kb","5kb","1kb","100b"]) pdrops = [] delays = [] init = 1 pdrop_re = re.compile(r'(\d+)% packet loss') delay_re = re.compile(r'rtt min/avg/max/mdev = (\d+).(\d+)/(\d+).(\d+)/(\d+).(\d+)/(\d+).(\d+) ms') bsizes.reverse() for bsize in bsizes: if init: init = 0 routercmd = "sudo tc qdisc add dev r-eth3 root tbf rate 18mbit limit {} burst 10kb".format(bsize) else: routercmd = "sudo tc qdisc replace dev r-eth3 root tbf rate 18mbit limit {} burst 10kb".format(bsize) r.cmdPrint(routercmd) h1.cmd("iperf -c 10.0.3.10 -u -b 20mb -t 30 -i 1 >>a1.txt &") h2.cmd("ping 10.0.3.10 -c 30 >> a2.txt") print("Sleeping 30 seconds") time.sleep(30) #Below is the code to analyse delay and packet dropdata f1 = open("a2.txt",'r') s = f1.read() f1.close() l1 = pdrop_re.findall(s) pdrop = l1[-1][0] pdrops.append(int(pdrop)) print("Packet Drop = {}%".format(pdrop)) l2 = delay_re.findall(s) delay = l2[-1][4] + '.' + l2[-1][5] delays.append(float(delay)) print("Delay = {} ms".format(delay)) bsizes = np.array(bsizes) delays = np.array(delays) pdrops = np.array(pdrops) plt.figure(0) plt.plot(bsizes,delays) plt.title("Delay") plt.savefig("delay.png") plt.show() plt.figure(1) plt.plot(bsizes,pdrops,'r') plt.title("Packet Drop %") plt.savefig("pdrop.png") plt.show() for h in [r, h1, h2, h3]: h.cmd('/usr/sbin/sshd') CLI( net ) net.stop() setLogLevel('info') main() However, when I run the program, only the delay increases with queue/buffer size as expected. The packet drop stays constant (apart from the initial 3% packet drop that occurs regardless of the queue size used). I am flummoxed by this, since theoretically, as buffer size decreases, the space to 'store' a packet on the queue decreases, therefore the chances of a packet getting dropped should increase, as per the tutorial. The graphs are shown below: Graph depicting an increase in delay: Graph depicting a stagnant packet drop: I need an explanation to this contrary behaviour. I would also appreciate a way to observe packet drop in my example. Could it have something to do with Mininet/SDNs in general prioritising ICMP over UDP packets, leading to a lack of packet drop? Or could it have something to do with controllers(I am using the default OpenFlow controller)?
Read SerialPort RealTime in HighSpeed Mode
I work on serial Port to read data. serial port's baud-rate is 921600 bps and i use these code to read data: while(true) { bytesToRead = sensor.BytesToRead; if (bytesToRead > 0) { byte[] input = new byte[bytesToRead]; sensor.Read(input, 0, bytesToRead); } } sending protocols is like this. (five digit numbers in bytes + \n\r ) 48 48 49 52 50 10 13 , .... that means : "00142\n\r" -> 00142 -> 142 in each loop I read 4096 bytes of data and i looking for fast way to read all numbers in buffer. i use readLine() function also but it is too slow and some data has been lost. is there any idea what shroud i do? thanks.
OpenCL only on AMD: CL_INVALID_ARG_SIZE
I have a kernel that runs on all platforms that I have access to, but AMD app SDK 3.0 with intel. The platform is: OpenCL.Device(Intel(R) Core(TM) i7-6700 CPU # 3.40GHz on AMD Accelerated Parallel Processing The MWE (sorry it's in Julia, but calls should be almost the same as in C): using OpenCL test_source = " struct __attribute__((packed)) Test{ float3 f1; int f2; float f3; }; __kernel void structest(struct Test a){} " device = first(cl.devices()) ctx = cl.Context(device) prg = cl.Program(ctx, source = test_source) queue = cl.CmdQueue(ctx) cl.build!(prg) structkernel = cl.Kernel(prg, "structest") astruct = ((1f0, 2f0, 3f0, 0f0), Int32(0), 22f0) sizeof(astruct) # == 24 exactly the same as what sizeof(struct Test a) in the kernel returns astruct_boxed = Ref(astruct) cl.#check cl.api.clSetKernelArg(structkernel.id, cl.cl_uint(0), sizeof(astruct), astruct_boxed) So I have confirmed, that the size of sizeof(astruct) and the size in the kernel match, but I still get an CL_INVALID_ARG_SIZE error. Is this a bug or am I missing something?
Arduino and Raspberry Pi Serial communication + multiple variables
I have a raspberry pi and an arduino. So far I have been able to have the Pi send data to the arduino using serial communication, however it only send one variable and I have multiple variables(2) that I want to send to the arduino (x,y coordinates). Does anyone know if this is possible. I want the first number that is sent from the pi to be the x and the second one the y and the next one the x of the next coord ect. I have tried editing the code that I use to send one variable but it doesn't work. Any help would be awesome
Consider the following method to send 2 variable at the same time: int xpos, ypos; char x_tx_buffer[20], y_tx_buffer[20]; char x_dummy_buffer[20]; char y_dummy_buffer[20]; char *p_x_tx_buffer, *p_y_tx_buffer; sprintf(x_dummy_buffer,"%d", xposs); sprintf(y_dummy_buffer,"%d", yposs); p_x_tx_buffer = &x_tx_buffer[0]; *p_x_tx_buffer++ = x_dummy_buffer[0]; *p_x_tx_buffer++ = x_dummy_buffer[1]; *p_x_tx_buffer++ = x_dummy_buffer[2]; *p_x_tx_buffer++ = x_dummy_buffer[3]; p_y_tx_buffer = &y_tx_buffer[0]; *p_y_tx_buffer++ = y_dummy_buffer[0]; *p_y_tx_buffer++ = y_dummy_buffer[1]; *p_y_tx_buffer++ = y_dummy_buffer[2]; *p_y_tx_buffer++ = y_dummy_buffer[3]; uart0_filestream = open("/dev/ttyAMA0", O_RDWR | O_NOCTTY | O_NDELAY); //Open in non blocking read/write mode if (uart0_filestream == -1) { //ERROR - CAN'T OPEN SERIAL PORT printf("Error - Unable to open UART. Ensure it is not in use by another application\n"); } if (uart0_filestream != -1) { int countx = write(uart0_filestream, &x_tx_buffer[0], (p_x_tx_buffer - &x_tx_buffer[0])); //Filestream, bytes to write, number of bytes to write int county = write(uart0_filestream, &y_tx_buffer[0], (p_y_tx_buffer - &y_tx_buffer[0])); //Filestream, bytes to write, number of bytes to write if (countx < 0 || county < 0) { printf("UART TX error\n"); } } close(uart0_filestream); You can send a max of 8 bytes at a time. Keep that in mind and with that you can modify the about code to send your x and y values in the same uart0_filestream. Good luck.
imap_client_buffer not being obeyed on nginx
I have imap_client_buffer set to 64k(as required by imap protocol) in the nginx.conf file However when an imap client sends a very long command, post authentication, the length gets truncated at 4k(the default page size of the linux operating system) how can i debug this problem? i have stepped through the code using gdb. as far as i can see, in mail_proxy module, the value of the conf file(120000 for testing) was correctly seen gdb) p p->upstream.connection->data $24 = (void *) 0x9e4bd48 (gdb) p s $25 = (ngx_mail_session_t *) 0x9e4bd48 (gdb) p p->buffer->end Cannot access memory at address 0x1c (gdb) p s->buffer->end - s->buffer->last $26 = 120000 (gdb) p s $27 = (ngx_mail_session_t *) 0x9e4bd48 (gdb) n 205 pcf = ngx_mail_get_module_srv_conf(s, ngx_mail_proxy_module); (gdb) n 207 s->proxy->buffer = ngx_create_temp_buf(s->connection->pool, (gdb) p pcf $28 = (ngx_mail_proxy_conf_t *) 0x9e3c480 (gdb) p *pcf $29 = {enable = 1, pass_error_message = 1, xclient = 1, buffer_size = 120000, timeout = 86400000, upstream_quick_retries = 0, upstream_retries = 0, min_initial_retry_delay = 3000, max_initial_retry_delay = 3000, max_retry_delay = 60000} When the command below is sent using telnet, only 4 k of data is accepted, then nginx hangs until i hit enter on keyboard......after which the truncated command is sent to the upstream imap server. I am using nginx 0.78, is this a known issue? This is the command sent HP1L UID FETCH 344990,344996,344998,345004,345006,345010:345011,345015,345020,345043,345046,345049:345050,345053,345057:345059,345071,345080,345083,345085,345090,345092:345093,345096,345101:345102,345106,345112,345117,345136,345140,345142:345144,345146:345147,345150,345161,345163,345167,345174:345176,345195,345197,345203,345205,345207:345209,345214,345218,345221,345224,345229,345231,345233,345236,345239,345248,345264,345267,345272,345285,345290,345292,345301,345305,345308,345316,345320,345322,345324,345327,345358,345375,345384,345386,345391,345409,345427:345428,345430:345432,345434:345435,345437,345439,345443,345448,345450,345463,345468:345470,345492,345494,345499,345501,345504,345506,345515:345519,345522,345525,345535,345563,345568,345574,345577,345580,345582,345599,345622,345626,345630,345632:345633,345637,345640,345647:345648,345675,345684,345686:345687,345703:345704,345714:345717,345720,345722:345724,345726,345730,345734:345737,345749,345756,345759,345783,345785:345787,345790,345806:345807,345812,345816,345720,345722:345724,345726,345730,345734:345737,345749,345756,345759,345783,345785:345787,345790,345806:345807,345812,345817,345902,345919,345953,345978,345981,345984,345990,345997,346004,346008:346009,346011:346012,346022,346039,346044,346050,346061:346062,346066:346067,346075:346076,346081,346088,346090,346093,346096,346098:346099,346110,346140,346170,346172:346174,346187,346189,346193:346194,346197,346204,346212,346225,346241,346244,346259,346323,346325:346328,346331:346332,346337:346338,346342,346346,346353,346361:346362,346364,346420,346426,346432,346447,346450:346451,346453:346454,346456:346457,346459:346460,346466:346468,346474,346476,346479,346483,346496,346498:346501,346504,346530,346539,346546,346576,346589:346590,346594:346595,346601,346607:346609,346612,346614:346615,346617:346618,346625,346631,346638,346641,346654,346657,346661,346665,346671,346687:346688,346693,346695,346734:346735,346741,346747:346748,346755,346757,346777,346779,346786:346788,346791,346793,346801,346815,346821:346822,346825,346828,346837,346839,346843,346848,346857:346858,346860,346862:346863,346866,346868:346869,346877,346883,346895:346897,346899,346923,346927,346945,346948,346961,346964:346966,346968,346970,346974,346987,346989:346990,346992,347000,347003,347008:347011,347013,347021,347028,347032:347034,347036,347049,347051,347058,347076,347079,347081,347083,347085,347092,347096,347108,347130,347145:347148,347150,347155:347158,347161,347163:347164,347181,347184,347187:347189,347204,347210:347211,347215,347217:347220,347227:347228,347234,347244,347246,347251,347253,347263:347264,347266,347268,347275,347292,347294,347304,347308,347317:347320,347322,347325:347327,347340:347341,347346,347352:347353,347357,347360:347361,347375,347379,347382:347386,347389,347392,347402,347405:347406,347411,347433:347434,347438,347440:347441,347443:347444,347448,347459:347460,347465,347468:347469,347476:347479,347490,347497,347506,347526,347530,347545,347547,347555:347556,347601:347605,347632,347634,347641,347643:347646,347649,347653,347660,347668,347676,347707,347719,347722,347724,347727:347732,347735,347746,347754,347756:347757,347761,347776,347779,347791,347798,347800,347805,347816:347817,347822,347837,347841,347843,347846,347848,347851,347879,347885,347892:347894,347903,347907:347911,347915:347916,347918,347950,347952:347953,347981,347986:347988,348001,348037:348038,348049,348052,348056:348058,348061,348072,348074,348077:348078,348080,348082,348100,348105,348109,348111:348116,348119:348123,348131:348132,348138,348150:348151,348153,348157,348161:348163,348166,348168:348169,348171,348173,348176,348178,348180:348181,348201,348204,348208,348218:348219,348222,348226,348229:348230,348235,348238:348240,348244:348247,348249,348251:348253,348256:348257,348263,348285,348288:348289,348293,348298:348299,348301:348302,348305:348306,348310,348327,348332:348337,348340,348342,348344,348348,348351:348353,348356:348357,348360,348366,348377,348386,348390,348398,348400:348401,348406:348407,348419,348422,348424,348427:348428,348430,348432:348433,348439,348444,348447:348448,348450:348451,348454,348456,348459:348460,348473,348493,348497:348498,348504,348506,348508,348516,348520,348527,348530,348532,348546:348547,348551,348560:348563,348567,348570:348572,348574,348577,348581,348588,348595,348610,348632,348636,348642,348646,348667,348672:348673,348679,348703,348713:348714,348716,348718:348722,348728:348729,348731,348735,348743:348745,348749,348751:348752,348759,348768,348773,348780:348781,348784:348791 (UID FLAGS)